/* NTXEfactura Self-Service Portal — Mobile-first, touch-optimized */
:root {
    --primary: #0078d4;
    --primary-dark: #005a9e;
    --primary-light: #e8f4fd;
    --success: #28a745;
    --success-light: #e8f5e9;
    --error: #dc3545;
    --error-light: #fce4ec;
    --warning: #ff9800;
    --bg: #f0f4f8;
    --card-bg: #ffffff;
    --text: #1a1a2e;
    --text-muted: #6b7280;
    --border: #d1d5db;
    --border-focus: #0078d4;
    --radius: 16px;
    --radius-sm: 10px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
    --shadow-hover: 0 8px 32px rgba(0, 0, 0, 0.12);
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f172a;
        --card-bg: #1e293b;
        --text: #e2e8f0;
        --text-muted: #94a3b8;
        --border: #334155;
        --primary-light: #1e3a5f;
        --success-light: #1a3a2a;
        --error-light: #3a1a1e;
        --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
    }
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-text-size-adjust: 100%;
}

/* ── Header ─────────────────────────────────── */
.app-header {
    background: linear-gradient(135deg, #0078d4, #00a4ef);
    color: white;
    padding: 12px 20px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 12px rgba(0, 120, 212, 0.3);
}

.header-content {
    max-width: 600px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo { display: flex; align-items: center; gap: 10px; }
.logo-text { font-size: 18px; font-weight: 700; letter-spacing: -0.5px; }

.lang-switch {
    color: white;
    text-decoration: none;
    background: rgba(255,255,255,0.2);
    padding: 6px 16px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 14px;
    transition: var(--transition);
    min-height: 44px;
    display: flex;
    align-items: center;
}

.lang-switch:hover { background: rgba(255,255,255,0.35); }

/* ── Wizard Container ──────────────────────── */
.wizard-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px 16px;
    flex: 1;
    width: 100%;
}

/* ── Progress Bar ──────────────────────────── */
.progress-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 24px;
    gap: 0;
}

.progress-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    opacity: 0.4;
    transition: var(--transition);
}

.progress-step.active { opacity: 1; }
.progress-step.done { opacity: 0.7; }

.step-dot {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.progress-step span { font-size: 11px; font-weight: 600; color: var(--text-muted); }
.progress-step.active span { color: var(--primary); }

.progress-line {
    flex: 1;
    height: 3px;
    background: var(--border);
    margin: 0 4px;
    margin-bottom: 18px;
    border-radius: 2px;
    max-width: 60px;
}

/* ── Cards ─────────────────────────────────── */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 28px 24px;
    box-shadow: var(--shadow);
    animation: slideUp 0.4s ease;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.card h2 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--text);
}

/* ── Wizard Steps ──────────────────────────── */
.wizard-step { display: none; }
.wizard-step.active { display: block; }

/* ── Form Elements ─────────────────────────── */
.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.input-large {
    width: 100%;
    padding: 14px 16px;
    font-size: 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--card-bg);
    color: var(--text);
    transition: var(--transition);
    min-height: 52px;
    -webkit-appearance: none;
}

.input-large:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(0, 120, 212, 0.15);
}

select.input-large { cursor: pointer; }

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.input-with-button {
    display: flex;
    gap: 8px;
}

.input-with-button .input-large { flex: 1; }
.input-with-button .btn { white-space: nowrap; min-height: 52px; }

.hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; display: block; }

/* ── GDPR ──────────────────────────────────── */
.gdpr-card h2 { color: var(--primary); }

.consent-box {
    background: var(--primary-light);
    border-radius: var(--radius-sm);
    padding: 20px;
    margin: 20px 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.checkbox-large {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    cursor: pointer;
    font-size: 14px;
    line-height: 1.5;
    min-height: 48px;
    padding: 4px 0;
}

.checkbox-large input[type="checkbox"] { display: none; }

.checkmark {
    width: 28px;
    height: 28px;
    min-width: 28px;
    border: 2px solid var(--border);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    background: var(--card-bg);
    margin-top: 2px;
}

.checkbox-large input:checked + .checkmark {
    background: var(--primary);
    border-color: var(--primary);
}

.checkbox-large input:checked + .checkmark::after {
    content: '✓';
    color: white;
    font-size: 16px;
    font-weight: bold;
}

.checkbox-large.inline { flex-direction: row; align-items: center; }

.cookie-notice {
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 16px;
}

/* ── Location Grid ─────────────────────────── */
.location-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
    margin-top: 10px;
    max-height: 300px;
    overflow-y: auto;
}

.location-card {
    background: var(--primary-light);
    border: 2px solid transparent;
    border-radius: var(--radius-sm);
    padding: 14px 12px;
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
    min-height: 72px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
}

.location-card:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: var(--shadow-hover); }
.location-card.selected { border-color: var(--primary); background: var(--primary); color: white; }
.location-card .loc-name { font-weight: 700; font-size: 14px; }
.location-card .loc-city { font-size: 12px; opacity: 0.7; }

/* ── Toggle Buttons ────────────────────────── */
.toggle-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.toggle-btn {
    flex: 1;
    min-width: 100px;
    padding: 14px 12px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--card-bg);
    color: var(--text);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    min-height: 52px;
}

.toggle-btn:hover { border-color: var(--primary); }
.toggle-btn.active { background: var(--primary); color: white; border-color: var(--primary); }

/* ── Buttons ───────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 14px 28px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    min-height: 52px;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, #0078d4, #00a4ef);
    color: white;
    box-shadow: 0 4px 16px rgba(0, 120, 212, 0.3);
}

.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(0, 120, 212, 0.4); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-secondary {
    background: var(--card-bg);
    color: var(--primary);
    border: 2px solid var(--primary);
}

.btn-secondary:hover { background: var(--primary-light); }

.btn-large { width: 100%; font-size: 17px; padding: 16px; }

.button-row { display: flex; gap: 12px; margin-top: 8px; }
.button-row .btn { flex: 1; }

/* ── Error Messages ────────────────────────── */
.error-message {
    background: var(--error-light);
    color: var(--error);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 500;
    margin: 12px 0;
    display: none;
}

.error-message.visible { display: block; animation: shake 0.4s ease; }

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-6px); }
    75% { transform: translateX(6px); }
}

/* ── Invoice Confirmation ──────────────────── */
.invoice-confirm {
    background: var(--success-light);
    border-radius: var(--radius-sm);
    padding: 20px;
    margin-bottom: 20px;
}

.invoice-confirm h3 { color: var(--success); font-size: 16px; margin-bottom: 12px; }

.invoice-details { display: flex; flex-direction: column; gap: 8px; }

.detail { display: flex; justify-content: space-between; }
.detail .label { font-weight: 600; color: var(--text-muted); }

/* ── Success Card ──────────────────────────── */
.success-card { text-align: center; }

.success-icon { font-size: 64px; margin-bottom: 16px; animation: bounceIn 0.6s ease; }

@keyframes bounceIn {
    0% { transform: scale(0); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.success-message { font-size: 18px; margin-bottom: 20px; color: var(--text-muted); }

.success-details {
    background: var(--success-light);
    border-radius: var(--radius-sm);
    padding: 16px;
    margin-bottom: 20px;
    text-align: left;
}

.success-details p { margin: 6px 0; font-size: 14px; }

/* ── Privacy Page ──────────────────────────── */
.privacy-card h1 { font-size: 24px; margin-bottom: 24px; color: var(--primary); }
.privacy-card h2 { font-size: 18px; margin-top: 24px; margin-bottom: 8px; }
.privacy-card p { margin-bottom: 8px; line-height: 1.6; }
.privacy-card ul { margin: 8px 0 8px 20px; }
.privacy-card li { margin-bottom: 6px; line-height: 1.5; }
.privacy-card a { color: var(--primary); }

/* ── Loading Spinner ───────────────────────── */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    margin-right: 8px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Footer ────────────────────────────────── */
.app-footer {
    text-align: center;
    padding: 20px;
    font-size: 12px;
    color: var(--text-muted);
}

.app-footer a { color: var(--primary); text-decoration: none; }
.app-footer a:hover { text-decoration: underline; }

/* ── Turnstile ─────────────────────────────── */
#turnstile-container {
    display: flex;
    justify-content: center;
    margin: 16px 0;
}

/* ── Responsive ────────────────────────────── */
@media (max-width: 480px) {
    .card { padding: 20px 16px; }
    .form-row { grid-template-columns: 1fr; }
    .toggle-group { flex-direction: column; }
    .toggle-btn { min-width: unset; }
    .location-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
    .button-row { flex-direction: column; }
    .input-with-button { flex-direction: column; }
}
