/* ==================== MOBILE RESPONSIVE — SUBPAGES ==================== */
/* Import AFTER theme-light.css. Fixes mobile responsiveness for:
   login, register, checkout, comparator, contact, legal, sell-phone, partner-register */

/* ── LEGAL PAGE — Mobile ── */
@media (max-width: 768px) {
    .legal-hero { padding: 100px 16px 40px; }
    .legal-hero h1 { font-size: 1.6rem; }
    .legal-hero p { font-size: .92rem; }
    .legal-tabs { margin: 24px auto 0; padding: 4px; gap: 2px; }
    .legal-tab { min-width: 120px; padding: 12px 14px; font-size: .82rem; }
    .legal-content { margin: 24px auto 60px; padding: 0 16px; }
    .legal-section h2 { font-size: 1.25rem; margin: 32px 0 12px; }
    .legal-section h3 { font-size: 1rem; }
    .legal-section p, .legal-section li { font-size: .88rem; line-height: 1.7; }
    .legal-card { padding: 20px 16px; }
    .legal-table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .legal-table th, .legal-table td { padding: 10px 12px; font-size: .82rem; white-space: nowrap; }
    .legal-step { gap: 12px; }
    .legal-step-num { width: 32px; height: 32px; font-size: .78rem; }
}
@media (max-width: 480px) {
    .legal-hero { padding: 80px 12px 32px; }
    .legal-hero h1 { font-size: 1.4rem; }
    .legal-tab { min-width: 100px; padding: 10px 10px; font-size: .78rem; }
    .legal-content { padding: 0 12px; }
}

/* ── CONTACT PAGE — Mobile ── */
@media (max-width: 768px) {
    .contact-page { padding: 100px 16px 60px; }
    .contact-header { margin-bottom: 40px; }
    .contact-header h1 { font-size: 1.6rem; }
    .contact-header p { font-size: .92rem; }
    .contact-grid { grid-template-columns: 1fr; gap: 16px; }
    .contact-card { padding: 24px 20px; }
    .company-section { padding: 32px 20px; }
    .company-section h2 { font-size: 1.1rem; }
    .company-grid { grid-template-columns: 1fr; gap: 24px; }
    .contact-form-section { padding: 32px 20px; }
    .contact-form-section h2 { font-size: 1.1rem; }
    .btn-send { width: 100%; min-height: 48px; font-size: .95rem; }
}
@media (max-width: 480px) {
    .contact-page { padding: 80px 12px 48px; }
    .contact-header h1 { font-size: 1.4rem; }
    .contact-card { padding: 20px 16px; }
    .company-section { padding: 24px 16px; }
    .contact-form-section { padding: 24px 16px; }
}

/* ── COMPARATOR PAGE — Mobile ── */
@media (max-width: 768px) {
    .comparator-page { padding-top: 80px; }
    .comparator-header h1 { font-size: 1.5rem; }
    .comparator-header p { font-size: .88rem; }
    .comparator-selectors { grid-template-columns: 1fr; gap: 16px; }
    .selector-card { padding: 20px; }
    .selector-preview { width: 100px; height: 100px; }
    .add-column-btn { min-height: 160px; padding: 20px; }
    .comparison-table-wrapper { -webkit-overflow-scrolling: touch; }
    .comparison-table th, .comparison-table td { padding: 10px 14px; font-size: .82rem; }
    .comparison-table th:first-child, .comparison-table td:first-child { width: 130px; min-width: 120px; }
    .table-product-img { width: 60px; height: 60px; }
    .table-cart-btn { padding: 10px 16px; font-size: .78rem; min-height: 44px; }
}
@media (max-width: 480px) {
    .comparator-page { padding-top: 70px; }
    .comparator-header h1 { font-size: 1.3rem; }
    .comparator-header { margin-bottom: 32px; padding: 0 4px; }
    .comparison-table { min-width: 500px; }
    .comparison-table th:first-child, .comparison-table td:first-child { width: 100px; min-width: 100px; font-size: .78rem; }
}

/* ── CHECKOUT PAGE — Mobile ── */
@media (max-width: 768px) {
    .checkout-page { padding: 70px 16px 32px; }
    .checkout-header h1 { font-size: 1.3rem; }
    .checkout-container { grid-template-columns: 1fr; gap: 20px; }
    .checkout-summary { position: static; }
    .form-card { padding: 20px 16px; }
    .form-card h2 { font-size: .95rem; }
    .payment-methods { grid-template-columns: 1fr; gap: 8px; }
    .payment-option { padding: 14px; min-height: 48px; }
    .summary-card { padding: 20px 16px; }
    .btn-checkout { min-height: 48px; font-size: 1rem; }
    .security-badges { flex-wrap: wrap; gap: 8px; }
}
@media (max-width: 480px) {
    .checkout-page { padding: 60px 12px 24px; }
    .checkout-header { flex-direction: column; gap: 8px; align-items: flex-start; }
    .form-card { padding: 16px 12px; border-radius: 12px; }
    .summary-card { padding: 16px 12px; border-radius: 12px; }
}

/* ── SELL-PHONE PAGE — Mobile ── */
@media (max-width: 768px) {
    .sell-header { padding: 16px 16px; }
    .sell-main { padding: 24px 16px 60px; }
    .sell-title h1 { font-size: 1.5rem; }
    .sell-title p { font-size: .88rem; }
    .sell-step h2 { font-size: 1.05rem; }
    .sf-group input, .sf-group select, .sf-group textarea { min-height: 48px; font-size: .88rem; }
    .estimation-card { padding: 24px 16px; }
    .estimation-price { font-size: 2.4rem; }
    .sell-actions { flex-direction: column-reverse; gap: 10px; }
    .btn-sell-next { min-height: 48px; font-size: .95rem; }
    .btn-sell-back { min-height: 48px; width: 100%; text-align: center; display: flex; align-items: center; justify-content: center; }
    .id-upload-slot { padding: 20px; }
    .responsibility-box { padding: 16px; }
    .signature-area { height: 100px; }
}
@media (max-width: 480px) {
    .sell-main { padding: 20px 12px 48px; }
    .sell-title h1 { font-size: 1.3rem; }
    .sell-badge { font-size: .55rem; }
    .estimation-price { font-size: 2rem; }
}

/* ── PARTNER REGISTER PAGE — Mobile ── */
@media (max-width: 768px) {
    .register-body .register-container { padding: 24px 16px 40px; }
    .register-body .register-header h1 { font-size: 1.4rem; }
    .register-body .form-card { padding: 24px 16px; }
    .register-body .field-row, .register-body .field-row.three { grid-template-columns: 1fr; }
    .register-body .field-group input, .register-body .field-group select, .register-body .field-group textarea { min-height: 48px; font-size: .9rem; }
    .register-body .step-connector { width: 24px; }
    .register-body .step-circle { width: 34px; height: 34px; font-size: .78rem; }
    .register-body .step-labels { display: none; }
    .register-body .twofa-options { flex-direction: column; }
    .register-body .password-requirements { grid-template-columns: 1fr; }
    .register-body .form-nav { flex-direction: column-reverse; gap: 10px; }
    .register-body .btn-nav { width: 100%; justify-content: center; min-height: 48px; }
    .register-body .register-topbar { padding: 16px; }
    .register-body .topbar-help { font-size: .78rem; }
    .register-body .upload-area { padding: 24px 16px; }
}
@media (max-width: 480px) {
    .register-body .register-container { padding: 16px 12px 32px; }
    .register-body .form-card { padding: 20px 12px; border-radius: 14px; }
    .register-body .step-connector { width: 14px; }
    .register-body .register-header h1 { font-size: 1.25rem; }
    .register-body .qr-placeholder { width: 140px; height: 140px; }
    .register-body .code-digit { width: 38px; height: 46px; font-size: 1.1rem; }
}

/* ==================== GLOBAL MOBILE SUBPAGE FIXES ==================== */
@media (max-width: 768px) {
    /* Prevent horizontal overflow on all pages */
    html, body { overflow-x: hidden; max-width: 100vw; }

    /* All form inputs — full-width with proper sizing, 16px prevents iOS zoom */
    .field input, .field select, .field textarea,
    .sf-group input, .sf-group select, .sf-group textarea,
    .field-group input, .field-group select, .field-group textarea {
        width: 100%;
        min-height: 44px;
        font-size: 16px;
    }

    /* All form-row grids collapse to single column */
    .form-row { grid-template-columns: 1fr; }

    /* Minimum 44px tap targets for all interactive elements */
    button, a.contact-link, .legal-tab, .payment-option,
    .register-btn, .login-btn, .btn-send, .btn-checkout,
    .btn-sell-next, .btn-sell-back, .btn-next, .btn-back, .btn-nav {
        min-height: 44px;
    }

    /* Container padding for 375px screens */
    .container { padding: 0 16px; }

    /* Cookie banner — stack content on mobile to avoid overflow */
    #cookieBanner {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 10px !important;
        padding: 14px 16px !important;
        font-size: 0.8rem !important;
    }
    #cookieBanner p { text-align: center; }
    #cookieBanner > div { width: 100%; justify-content: center; }
    #cookieBanner button { flex: 1; min-height: 44px; min-width: 44px; }

    /* Dashboard tables: ensure horizontal scroll wrapper */
    .table-wrapper,
    .legal-table-wrapper,
    .comparison-table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        max-width: 100%;
    }

    /* Ensure modals fit screen */
    .modal, .modal-content, .modal-card {
        max-width: calc(100vw - 24px);
        max-height: calc(100vh - 24px);
        overflow-y: auto;
    }

    /* Admin export panel stacking on very narrow screens */
    .export-panel {
        grid-template-columns: 1fr 1fr !important;
    }

    /* Text min size enforcement — prevent tiny text on mobile (>= 12px minimum for visible labels) */
    small, .text-small, .meta, .caption { font-size: 0.75rem; }
}

@media (max-width: 480px) {
    /* Cookie banner buttons stack */
    #cookieBanner > div {
        flex-direction: row;
        gap: 8px !important;
    }

    /* Further admin kpi card constraint */
    .admin-kpi-row { grid-template-columns: 1fr 1fr !important; }

    /* Ensure no element exceeds viewport width */
    .container, .checkout-container, .contact-container,
    .comparator-page, .legal-content, .dash-page {
        max-width: 100vw;
    }
}

/* ============================================================
   A11Y HARDENING — covers pages that only load mobile-subpages.css
   (login-*, register-*, partner-register, dashboards, etc.)
   ============================================================ */

/* Focus-visible — universal fallback (WCAG 2.4.7) */
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[role="button"]:focus-visible,
[tabindex]:focus-visible {
    outline: 2px solid #B8953F;
    outline-offset: 2px;
}
/* Gold-accented focus on dashboards + admin */
.dashboard-body button:focus-visible,
.dashboard-body a:focus-visible,
.dashboard-body input:focus-visible,
.dashboard-body select:focus-visible,
.dashboard-body textarea:focus-visible,
.register-body button:focus-visible,
.register-body a:focus-visible,
.register-body input:focus-visible,
.register-body select:focus-visible {
    outline: 2px solid #B8953F;
    outline-offset: 2px;
}

/* Prefers-reduced-motion — dashboard/auth coverage */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Tap target / font-size floors on mobile for subpages */
@media (max-width: 768px) {
    /* 44×44 minimum for all buttons and interactive anchors */
    button,
    .login-btn,
    .register-btn,
    .btn,
    .btn-send,
    .btn-checkout,
    .btn-sell-next,
    .btn-sell-back,
    .btn-nav,
    .btn-next,
    .btn-back,
    .sidebar-toggle,
    .topbar-notif,
    .legal-tab,
    .payment-option,
    .add-column-btn,
    .table-cart-btn,
    a.contact-link,
    .form-actions .btn,
    .lang-option,
    .lang-selector,
    .nav-btn,
    .nav-hamburger,
    .search-close,
    .modal-close,
    .product-modal-close,
    [class*="close-btn"] {
        min-height: 44px;
    }
    .nav-btn,
    .nav-hamburger,
    .sidebar-toggle,
    .topbar-notif,
    .search-close,
    .modal-close,
    .product-modal-close {
        min-width: 44px;
    }

    /* Font-size floors — avoid <14px body copy */
    body, p, li,
    .login-form label,
    .login-form .login-subtitle,
    .login-options label,
    .field-group label,
    .form-group label,
    .sf-group label,
    .field label,
    .legal-section p,
    .legal-section li,
    .contact-card p,
    .sidebar-link,
    .dash-table td,
    .dash-table th {
        font-size: max(14px, 1em);
    }

    /* Inputs — 16px prevents iOS zoom and ensures 44px+ height */
    input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="hidden"]),
    select,
    textarea {
        font-size: 16px;
        min-height: 44px;
    }

    /* Link identification on body copy */
    main a:not(.btn):not(.login-btn):not(.register-btn):not(.nav-link):not(.sidebar-link):not(.footer-link):not(.contact-card):not(.contact-link):not(.legal-tab):not(.btn-nav):not(.payment-option):not(.table-cart-btn):not(.scroll-indicator) {
        text-decoration: underline;
        text-underline-offset: 2px;
    }
}

/* iPhone SE / 375px and below */
@media (max-width: 375px) {
    .login-card,
    .register-body .form-card,
    .form-card {
        padding: 20px 14px !important;
    }
    .login-page {
        padding: 14px;
    }
    /* Always-visible focus rings even with limited space */
    *:focus-visible {
        outline-offset: 1px;
    }
}

/* SR-only utility for aria live regions / visually-hidden labels */
.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0,0,0,0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* ============================================================
   FINAL-PASS SUBPAGE HARDENING — gaps found in audit
   ============================================================ */

/* CHECKOUT — step bar visible + readable at 375px */
@media (max-width: 480px) {
    .checkout-steps,
    .steps-bar,
    .checkout-progress {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
        padding: 10px 8px;
        font-size: 0.72rem;
        justify-content: center;
    }
    .checkout-step,
    .progress-step {
        font-size: 0.7rem;
        gap: 4px;
    }
    .step-number,
    .progress-step-num {
        width: 24px;
        height: 24px;
        font-size: 0.7rem;
    }
    /* Order summary collapses cleanly */
    .summary-line,
    .summary-item {
        font-size: 0.85rem;
        flex-wrap: wrap;
    }
    .checkout-form .field-row {
        grid-template-columns: 1fr !important;
    }
}

/* SELL-PHONE — 5-step usability final pass */
@media (max-width: 480px) {
    /* Step indicator (top of sell-phone) — keep visible */
    .sell-stepper,
    .sell-progress {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 4px;
        padding: 8px 0;
    }
    .sell-step-indicator {
        flex: 0 0 auto;
        font-size: 0.7rem;
    }
    /* Estimation card stays readable */
    .estimation-card {
        text-align: center;
    }
    .estimation-meta,
    .estimation-detail {
        flex-direction: column;
        gap: 6px;
        align-items: center;
    }
    /* Signature reset button */
    .signature-clear-btn,
    .btn-clear-signature {
        min-height: 44px;
        width: 100%;
        margin-top: 8px;
    }
    /* ID upload slot full width */
    .id-upload {
        flex-direction: column !important;
    }
    .id-upload-slot {
        width: 100% !important;
    }
    /* Accessory grid 1-col */
    .accessory-grid {
        grid-template-columns: 1fr !important;
    }
    /* Responsibility / disclosure boxes wrap */
    .responsibility-box {
        font-size: 0.82rem;
        line-height: 1.5;
    }
}

/* DASHBOARDS — sidebar/topbar/KPI final adjustments */
@media (max-width: 480px) {
    /* Topbar: hide search, keep notif + toggle visible */
    .dash-topbar {
        flex-wrap: nowrap;
    }
    .topbar-actions {
        gap: 4px;
        flex-shrink: 0;
    }
    /* Sidebar full-width when open */
    .sidebar.open {
        width: 100% !important;
        max-width: 320px;
    }
    /* Workflow banner readable */
    .workflow-banner h3,
    .workflow-title {
        font-size: 0.92rem;
    }
    /* Status pills don't overflow */
    .status-pill,
    .badge,
    .tag {
        font-size: 0.7rem;
        padding: 4px 8px;
    }
}

/* CONTACT — form fields full-width */
@media (max-width: 480px) {
    .contact-form .field-row {
        grid-template-columns: 1fr !important;
        gap: 12px;
    }
    .contact-card-icon {
        width: 44px;
        height: 44px;
    }
    .contact-card h3 {
        font-size: 1rem;
    }
    .contact-card p,
    .contact-card a {
        font-size: 0.85rem;
        word-break: break-word;
    }
}

/* COMPARATOR — table is scrollable, selector cards stack */
@media (max-width: 480px) {
    .selector-card {
        padding: 16px !important;
    }
    .selector-preview {
        width: 80px !important;
        height: 80px !important;
    }
    .add-column-btn {
        min-height: 120px !important;
    }
    /* Comparator table scroll hint */
    .comparison-table-wrapper::after {
        content: '';
        display: block;
        height: 4px;
    }
}

/* LEGAL — tabs scroll horizontally instead of wrapping */
@media (max-width: 480px) {
    .legal-tabs {
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        justify-content: flex-start;
        padding: 4px 8px;
        scrollbar-width: thin;
    }
    .legal-tab {
        flex: 0 0 auto;
        white-space: nowrap;
    }
}

/* ADMIN — final responsive */
@media (max-width: 480px) {
    .admin-bottom-grid {
        grid-template-columns: 1fr !important;
    }
    .alert-card {
        flex-direction: column;
        align-items: flex-start;
    }
    .alert-actions {
        width: 100%;
    }
}

/* PARTNER REGISTER — step bar stays usable on iPhone SE */
@media (max-width: 375px) {
    .register-body .step-circle {
        width: 28px;
        height: 28px;
        font-size: 0.7rem;
    }
    .register-body .step-connector {
        width: 8px;
    }
    .register-body .form-card {
        padding: 16px 10px !important;
    }
}

/* Universal: prevent any horizontal scroll trigger from absolutely-positioned children */
@media (max-width: 768px) {
    .login-page,
    .register-body,
    .dashboard-body,
    .sell-body,
    .checkout-page,
    .contact-page,
    .comparator-page,
    .legal-page {
        overflow-x: hidden;
    }
    /* Decorative absolute elements clipped */
    .login-page::before,
    .login-page::after,
    .register-page::before,
    .register-page::after {
        max-width: 100vw;
        overflow: hidden;
    }
}
