:root {
    --primary: #0066ff;
    --primary-dark: #0052cc;
    --success: #00c853;
    --error: #ff3d00;
    --text: #1a1a1a;
    --text-light: #666;
    --bg: #f5f7fa;
    --card-bg: #ffffff;
    --border: #e0e6ed;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    --radius: 16px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

body.has-support-float {
    /* Keep page content from being covered by the fixed bottom bar */
    padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px));
}

.container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.card {
    background: var(--card-bg);
    border-radius: 24px;
    box-shadow: var(--shadow);
    max-width: 480px;
    width: 100%;
    padding: 32px 24px;
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 24px;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #e6f0ff;
    color: var(--primary);
    padding: 8px 16px;
    border-radius: 50px;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 16px;
}

.icon {
    font-size: 48px;
    margin-bottom: 12px;
}

h1 {
    font-size: 32px;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 8px;
    color: var(--text);
}

.subtitle {
    color: var(--text-light);
    font-size: 15px;
}

/* Welcome */
.welcome {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    border-radius: var(--radius);
    margin-bottom: 28px;
}

.welcome strong {
    display: block;
    margin-bottom: 8px;
    font-size: 16px;
}

.welcome p {
    font-size: 14px;
    line-height: 1.5;
    opacity: 0.95;
}

/* Form */
.form-group {
    margin-bottom: 20px;
}

label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text);
}

.hint {
    font-size: 12px;
    font-weight: 400;
    color: var(--text-light);
}

.form-input {
    width: 100%;
    padding: 14px 16px;
    font-size: 16px;
    border: 2px solid var(--border);
    border-radius: 12px;
    outline: none;
    transition: all 0.2s;
    background: var(--card-bg);
}

.form-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(0, 102, 255, 0.1);
}

.input-with-scan {
    position: relative;
    display: flex;
    align-items: center;
}

.input-with-scan .form-input {
    padding-right: 100px;
}

.scan-btn {
    position: absolute;
    right: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.scan-btn:active {
    transform: scale(0.96);
    background: var(--primary-dark);
}

.error {
    display: block;
    color: var(--error);
    font-size: 13px;
    margin-top: 6px;
}

.scan-status {
    margin-top: 10px;
    padding: 12px 14px;
    border-radius: 12px;
    background: #f3f6fb;
    color: var(--text-light);
    font-size: 13px;
    line-height: 1.45;
    border: 1px solid #e2e8f0;
}

.scan-status.is-loading {
    background: #eef4ff;
    color: var(--primary);
    border-color: #cdddff;
}

.scan-status.is-success {
    background: #e9f8ef;
    color: #1b8f45;
    border-color: #bce7ca;
    font-weight: 600;
}

.scan-status.is-warning {
    background: #fff7e8;
    color: #a86a00;
    border-color: #f3d49b;
}

.scan-status.is-error {
    background: #fff0f0;
    color: #c0392b;
    border-color: #f1b8b1;
}

.scan-debug {
    margin-top: 10px;
    background: #101820;
    border-radius: 12px;
    padding: 10px;
}

.scan-debug-output {
    margin: 0 0 10px;
    padding: 10px;
    background: #0a1118;
    color: #89f7b5;
    font-size: 11px;
    line-height: 1.45;
    border-radius: 8px;
    max-height: 180px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

.scan-debug-copy {
    width: 100%;
    border: 1px solid #2e4a5f;
    background: #162430;
    color: #d8e7f5;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

.scan-btn:disabled,
.submit-btn:disabled,
.processing-manual-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.processing-overlay {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(12, 18, 28, 0.58);
    backdrop-filter: blur(6px);
    z-index: 1200;
}

.processing-overlay.is-active {
    display: flex;
}

.processing-overlay-card {
    width: min(100%, 380px);
    background: rgba(255, 255, 255, 0.98);
    border-radius: 22px;
    padding: 28px 24px;
    box-shadow: 0 24px 60px rgba(12, 18, 28, 0.25);
    text-align: center;
}

.processing-overlay-card h3 {
    margin: 0 0 10px;
    font-size: 22px;
    line-height: 1.2;
    color: var(--text);
}

.processing-overlay-card p {
    margin: 0;
    font-size: 14px;
    line-height: 1.55;
    color: var(--text-light);
}

.processing-spinner {
    width: 56px;
    height: 56px;
    margin: 0 auto 18px;
    border-radius: 50%;
    border: 4px solid rgba(0, 102, 255, 0.14);
    border-top-color: var(--primary);
    animation: processing-spin 0.9s linear infinite;
}

.processing-manual-btn {
    margin-top: 18px;
    width: 100%;
    border: none;
    border-radius: 12px;
    padding: 12px 16px;
    background: #ebf2ff;
    color: var(--primary-dark);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
}

@keyframes processing-spin {
    to {
        transform: rotate(360deg);
    }
}

.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 14px;
}

.alert-success {
    background: #e8f5e9;
    color: #2e7d32;
}

.alert-error {
    background: #ffebee;
    color: #c62828;
}

.submit-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 12px;
    padding: 16px;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    margin-top: 8px;
}

.submit-btn:active {
    transform: scale(0.98);
}

/* Benefits */
.benefits {
    display: flex;
    gap: 12px;
    margin: 20px 0;
    flex-wrap: wrap;
}

.benefit {
    flex: 1;
    min-width: 140px;
    background: #f0f4f8;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    text-align: center;
    color: var(--text);
}

/* Support */
.support {
    background: #f8fafc;
    border-radius: var(--radius);
    padding: 20px;
    margin-top: 24px;
}

.support h3 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    margin-bottom: 12px;
    color: var(--text);
}

.support-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: white;
    padding: 12px 16px;
    border-radius: 10px;
    margin-bottom: 8px;
    text-decoration: none;
    color: var(--primary);
    font-weight: 600;
    font-size: 14px;
    transition: all 0.2s;
}

.support-link:active {
    transform: scale(0.98);
}

.support-link.whatsapp {
    background: #e8f5e9;
    color: #25d366;
}

.badge-small {
    background: #e6f0ff;
    color: var(--primary);
    padding: 4px 10px;
    border-radius: 50px;
    font-size: 11px;
    font-weight: 700;
}

.support-note {
    text-align: center;
    font-size: 12px;
    color: var(--text-light);
    margin-top: 12px;
}

/* Fixed bottom WhatsApp bar */
.support-float-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
    background: rgba(248, 250, 252, 0.92);
    border-top: 1px solid rgba(224, 230, 237, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 900;
}

.support-float-inner {
    max-width: 480px;
    margin: 0 auto;
    display: flex;
    gap: 10px;
}

.support-float-link {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    border-radius: 12px;
    padding: 12px 10px;
    font-weight: 800;
    font-size: 13px;
    letter-spacing: 0.1px;
    border: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
    transition: transform 0.2s;
    text-align: center;
    line-height: 1.2;
}

.support-float-link:active {
    transform: scale(0.98);
}

.support-float-link.whatsapp {
    background: #e8f5e9;
    color: #1b8f45;
    border-color: rgba(37, 211, 102, 0.28);
}

@media (max-width: 380px) {
    .support-float-inner {
        flex-direction: column;
    }
    body.has-support-float {
        padding-bottom: calc(148px + env(safe-area-inset-bottom, 0px));
    }
}

/* Privacy */
.privacy {
    text-align: center;
    font-size: 12px;
    color: var(--text-light);
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

/* Scanner Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: #1a1a1a;
    border-radius: 20px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: rgba(255, 255, 255, 0.05);
}

.modal-header h3 {
    color: white;
    font-size: 18px;
    margin: 0;
}

.close-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    font-size: 28px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.close-btn:active {
    background: rgba(255, 255, 255, 0.2);
}

.scanner-viewport {
    position: relative;
    background: #000;
    aspect-ratio: 4/3;
    overflow: hidden;
}

#scannerVideo {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.scan-frame {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 280px;
    height: 200px;
    pointer-events: none;
}

.corner {
    position: absolute;
    width: 30px;
    height: 30px;
    border: 3px solid var(--primary);
}

.corner.tl {
    top: 0;
    left: 0;
    border-right: none;
    border-bottom: none;
    border-radius: 8px 0 0 0;
}

.corner.tr {
    top: 0;
    right: 0;
    border-left: none;
    border-bottom: none;
    border-radius: 0 8px 0 0;
}

.corner.bl {
    bottom: 0;
    left: 0;
    border-right: none;
    border-top: none;
    border-radius: 0 0 0 8px;
}

.corner.br {
    bottom: 0;
    right: 0;
    border-left: none;
    border-top: none;
    border-radius: 0 0 8px 0;
}

.modal-footer {
    padding: 20px;
    background: rgba(255, 255, 255, 0.05);
}

.scan-result {
    color: white;
    text-align: center;
    margin-bottom: 16px;
    font-size: 14px;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.btn-secondary,
.btn-primary {
    flex: 1;
    min-width: 120px;
    padding: 14px;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.btn-secondary:active {
    background: rgba(255, 255, 255, 0.2);
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:disabled {
    background: #333;
    color: #666;
    cursor: not-allowed;
}

.btn-primary:not(:disabled):active {
    transform: scale(0.96);
}

@media (max-width: 480px) {
    .modal-actions {
        gap: 10px;
    }

    .modal-actions .btn-secondary,
    .modal-actions .btn-primary {
        min-width: calc(50% - 5px);
    }

    .modal-actions .btn-primary {
        width: 100%;
    }
}

/* Success Page */
.success-card {
    text-align: center;
}

.success-icon {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, #00c853 0%, #00e676 100%);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    margin: 0 auto 24px;
}

.success-message {
    font-size: 16px;
    color: var(--text-light);
    margin-bottom: 32px;
}

.success-details {
    text-align: left;
    margin-bottom: 24px;
}

.detail-item {
    background: #f8fafc;
    padding: 16px;
    border-radius: 12px;
    margin-bottom: 12px;
}

.detail-item strong {
    display: block;
    margin-bottom: 6px;
    color: var(--text);
}

.detail-item p {
    font-size: 14px;
    color: var(--text-light);
}

.detail-item a {
    color: var(--primary);
    text-decoration: none;
}

.btn-back {
    display: inline-block;
    padding: 12px 24px;
    background: var(--primary);
    color: white;
    text-decoration: none;
    border-radius: 10px;
    font-weight: 600;
    transition: all 0.2s;
}

.btn-back:active {
    transform: scale(0.96);
}

/* Responsive */
@media (max-width: 480px) {
    .card {
        padding: 24px 20px;
    }

    h1 {
        font-size: 28px;
    }

    .scan-frame {
        width: 240px;
        height: 160px;
    }
}
