
/* ==========================================================================
   PHASE 2: WOODPECKER MOBILE REVAMP
   Target: max-width: 767px  |  Desktop (≥768px) untouched
   ========================================================================== */

/* --------------------------------------------------------------------------
   M-1: VIEWPORT FIT — Global overflow & word-wrap safety
   -------------------------------------------------------------------------- */
html {
    overflow-x: hidden;
    max-width: 100vw;
}

body {
    overflow-x: hidden;
    max-width: 100vw;
}

/* Force long strings (Project IDs, emails, INR figures) to never overflow */
.badge-wood-pill,
.badge-pill,
[style*="monospace"],
.dashboard-panel,
.quotation-card-item,
.auth-card {
    overflow-wrap: break-word;
    word-break: break-word;
}

/* Tables inside scrollable wrappers need a minimum to allow scrolling */
.table-scroll-wrap table,
div[style*="overflow-x: auto"] table {
    min-width: 480px;
}

/* --------------------------------------------------------------------------
   M-2: SCROLL PERFORMANCE — Reduce expensive compositing on mobile
   -------------------------------------------------------------------------- */

/* Use will-change only on horizontal scroll lanes */
.horizontal-scroll-lane {
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    will-change: scroll-position;
}

/* Promote modal dialogs to their own layer for smooth open/close */
.support-modal-dialog {
    will-change: transform;
}

/* Lazy-loaded images: prevent layout shift */
img[loading="lazy"] {
    content-visibility: auto;
}

/* --------------------------------------------------------------------------
   M-3: TOUCH TARGETS — Enforce 44×44px minimums globally
   -------------------------------------------------------------------------- */
.hamburger-btn,
.theme-toggle-btn {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
}

.close-menu-btn,
.modal-close-btn {
    min-width: 44px;
    min-height: 44px;
    padding: 0.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* --------------------------------------------------------------------------
   M-4: HOVER EFFECTS — Only fire on devices with real hover
   -------------------------------------------------------------------------- */
@media (hover: hover) and (pointer: fine) {
    .journey-step-card:hover {
        transform: translateY(-4px);
        box-shadow: var(--shadow-lg);
        border-color: var(--wood-primary);
    }

    .designer-card:hover {
        transform: translateY(-5px);
        box-shadow: var(--shadow-xl);
        border-color: var(--wood-primary);
    }

    .designer-scroll-card:hover {
        transform: translateY(-2px);
    }
}

/* Remove transforms on touch devices to prevent tap jank */
@media (hover: none) {
    .journey-step-card:hover,
    .designer-card:hover,
    .designer-scroll-card:hover,
    .dashboard-panel:hover {
        transform: none;
    }
}

/* --------------------------------------------------------------------------
   M-5: MOBILE-ONLY OVERRIDES  (max-width: 767px)
   -------------------------------------------------------------------------- */
@media (max-width: 767px) {

    /* ---- Container: 1rem gutters on mobile ---- */
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    /* ---- Navbar: reduce backdrop-filter cost on mobile ---- */
    .site-header {
        height: 64px;
        /* Reduce to lighter blur on mobile for 60fps scroll */
        backdrop-filter: blur(6px);
        -webkit-backdrop-filter: blur(6px);
    }

    /* Nav height variable sync */
    :root {
        --nav-height: 64px;
    }

    /* ---- Brand logo: responsive scaling & overflow-proof layout ---- */
    .brand-logo {
        font-size: clamp(0.95rem, 4.2vw, 1.2rem) !important;
        gap: clamp(0.35rem, 1.2vw, 0.5rem) !important;
        min-width: 0 !important;
        flex-shrink: 1 !important;
        white-space: nowrap !important;
        overflow: hidden;
    }

    .brand-logo-img,
    .brand-logo-icon {
        width: clamp(24px, 5.5vw, 30px) !important;
        height: clamp(24px, 5.5vw, 30px) !important;
        flex-shrink: 0 !important;
    }

    .logo-text {
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        display: inline-flex !important;
        align-items: baseline !important;
        min-width: 0 !important;
    }

    /* ---- Header actions: compress on mobile & relocate auth to drawer ---- */
    .header-actions {
        gap: 0.4rem;
        flex-shrink: 0 !important;
    }

    /* Hide desktop auth buttons/avatar completely from mobile header (< 768px) */
    .header-auth-desktop {
        display: none !important;
    }

    /* ---- Hamburger Toggle Button on Mobile: Guaranteed High Visibility & Tap Response ---- */
    .hamburger-btn {
        display: flex !important;
        position: relative;
        z-index: 50;
        cursor: pointer !important;
        pointer-events: auto !important;
        background: var(--bg-surface) !important;
        border: 1px solid var(--border) !important;
    }

    .hamburger-btn .bar {
        background: var(--text-heading, #1e293b) !important;
        height: 2.5px !important;
        pointer-events: none;
    }

    /* ---- Mobile drawer: 100% solid opaque background & high-contrast dark overlay ---- */
    .mobile-menu-overlay {
        position: fixed !important;
        inset: 0 !important;
        background: rgba(0, 0, 0, 0.70) !important;
        backdrop-filter: blur(4px) !important;
        -webkit-backdrop-filter: blur(4px) !important;
        z-index: 9998 !important;
    }

    .mobile-menu {
        position: fixed !important;
        top: 0 !important;
        width: min(88vw, 320px) !important;
        height: 100vh !important;
        height: 100dvh !important;
        right: calc(-1 * min(88vw, 320px) - 20px) !important;
        background-color: #FFFFFF !important;
        opacity: 1 !important;
        box-shadow: -8px 0 32px rgba(0, 0, 0, 0.35) !important;
        z-index: 9999 !important;
        overscroll-behavior: contain;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    }

    [data-theme="dark"] .mobile-menu {
        background-color: #1A1D21 !important;
        opacity: 1 !important;
    }

    .mobile-menu.active {
        right: 0 !important;
    }

    /* ---- Mobile nav links: larger tap targets ---- */
    .mobile-nav-link {
        padding: 0.75rem 0;
        min-height: 48px;
        display: flex;
        align-items: center;
    }

    /* ---- Hero section: mobile spacing ---- */
    .hero-section-mobile {
        padding: 2.5rem 0 3rem 0 !important;
    }

    .hero-h1-mobile {
        font-size: clamp(1.9rem, 7vw, 2.8rem) !important;
        letter-spacing: -0.5px !important;
        line-height: 1.2 !important;
    }

    .hero-sub-mobile {
        font-size: clamp(0.95rem, 4vw, 1.1rem) !important;
        margin-bottom: 1.75rem !important;
    }

    /* Hero image: fluid height instead of fixed 460px */
    .hero-img-mobile {
        height: clamp(200px, 48vw, 380px) !important;
    }

    /* Hero CTA row: stack on small phones */
    .hero-cta-row {
        gap: 0.65rem;
    }

    .hero-cta-row .btn {
        font-size: 0.88rem;
        padding: 0.7rem 1.1rem;
    }

    /* ---- Pillars grid: 1 column on mobile ---- */
    .pillars-grid-mobile {
        grid-template-columns: 1fr !important;
    }

    /* ---- Section headers ---- */
    .section-header h2 {
        font-size: clamp(1.35rem, 5.5vw, 1.9rem) !important;
    }

    .section-header p {
        font-size: 0.95rem;
    }

    /* ---- Journey grid: 1 col on mobile ---- */
    .journey-grid {
        grid-template-columns: 1fr !important;
    }

    /* ---- Universal Grids -> 1 col on mobile ---- */
    .grid-2,
    .grid-3,
    .grid-4,
    .contact-layout,
    .support-main-layout,
    .designer-calendar-layout,
    .designers-directory-grid {
        grid-template-columns: 1fr !important;
        gap: 1.5rem !important;
    }

    /* ---- Stats grid: 2 col → 1 col on tiny phones ---- */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }

    .stat-num {
        font-size: 2rem;
    }

    /* Remove divider pseudo-elements in 1-col stat layout */
    .stat-item-box::after {
        display: none !important;
    }

    /* ---- Auth dual grid: 1 col ---- */
    .auth-dual-grid {
        grid-template-columns: 1fr !important;
    }

    /* ---- Auth card: comfortable mobile padding ---- */
    .auth-card {
        padding: 1.5rem 1.25rem;
    }

    /* ---- Form controls: enforce 16px to prevent iOS auto-zoom ---- */
    input,
    select,
    textarea,
    .form-control {
        font-size: 16px !important;
        min-height: 44px;
    }

    /* Keep labels and small text at correct size */
    .form-group label,
    .form-footnote,
    small {
        font-size: 0.875rem;
    }

    /* ---- Form row 2-col: stack on mobile ---- */
    .form-row-2 {
        grid-template-columns: 1fr !important;
        gap: 0;
    }

    /* ---- File upload dropzone: taller touch area ---- */
    .file-upload-dropzone {
        padding: 2rem 1rem;
        min-height: 100px;
    }

    /* ---- Dashboard panel: reduce padding ---- */
    .dashboard-panel {
        padding: 1.25rem 1rem;
        box-shadow: 0 1px 4px rgba(140, 98, 57, 0.06); /* lighter shadow on mobile */
    }

    /* Dashboard header: stack on mobile */
    .dashboard-header-flex {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.85rem;
    }

    .dashboard-user-greeting h1 {
        font-size: clamp(1.4rem, 5.5vw, 1.75rem) !important;
    }

    .dashboard-actions-right {
        width: 100%;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .dashboard-actions-right .btn {
        flex: 1 1 auto;
        min-width: 120px;
        font-size: 0.85rem;
    }

    /* Dashboard panel title: wrap gracefully */
    .dashboard-panel-title {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .dashboard-panel-title h2 {
        font-size: 1.1rem;
    }

    /* ---- Quotation filter tabs: horizontal scroll with snap ---- */
    .quotes-filter-tabs {
        display: flex !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        scroll-snap-type: x mandatory !important;
        scrollbar-width: none !important;
        gap: 0.5rem !important;
        padding-bottom: 0.5rem !important;
        border-bottom: 1px solid var(--border) !important;
        margin-bottom: 0.25rem !important;
    }

    .quotes-filter-tabs::-webkit-scrollbar {
        display: none;
    }

    .quotes-filter-tabs .quote-tab-btn,
    .quotes-filter-tabs .btn {
        flex-shrink: 0 !important;
        scroll-snap-align: start !important;
        white-space: nowrap !important;
        font-size: 0.82rem !important;
        padding: 0.5rem 0.85rem !important;
        min-height: 40px;
    }

    /* ---- Quotation card: mobile-friendly layout ---- */
    .quotation-card-item {
        padding: 1.1rem !important;
    }

    /* Quote card action buttons: stack on mobile */
    .quote-card-actions {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0.65rem !important;
    }

    .quote-card-secondary-actions {
        width: 100%;
        flex-direction: column;
    }

    .quote-card-secondary-actions .btn,
    .quote-card-actions > div:last-child .btn,
    .quote-card-actions > div:last-child a {
        width: 100% !important;
        justify-content: center !important;
        font-size: 0.88rem !important;
    }

    /* ---- Horizontal scroll lane: smaller cards on mobile ---- */
    .designer-scroll-card {
        flex: 0 0 min(85vw, 280px);
    }

    /* ---- Modal dialogs: fit mobile ---- */
    .support-modal-backdrop {
        padding: 0.75rem;
        align-items: flex-end; /* sheet-style from bottom on mobile */
    }

    .support-modal-dialog {
        max-width: 100% !important;
        width: 100% !important;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0 !important;
        max-height: 92vh;
        margin: 0;
    }

    .support-modal-header {
        padding: 1.25rem 1.25rem 1rem 1.25rem;
    }

    .support-modal-body {
        padding: 1.25rem !important;
    }

    .support-header-info h2 {
        font-size: 1.2rem;
    }

    /* Modal full-width buttons on mobile */
    .support-modal-body .btn-wood,
    .support-modal-body .btn-outline-wood {
        width: 100%;
        justify-content: center;
        margin-bottom: 0.5rem;
    }

    /* ---- Calendar slot grid: 2 col on mobile ---- */
    .calendar-slot-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }

    .slot-toggle-pill {
        font-size: 0.72rem;
        padding: 0.4rem 0.2rem;
        min-height: 40px;
    }

    /* ---- Quotation builder: stack the room form rows ---- */
    .room-item-row .form-row,
    .room-item-row .form-row-2 {
        grid-template-columns: 1fr !important;
    }

    /* ---- Quote total summary: stack value ---- */
    .quote-total-summary {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
        padding: 1rem;
    }

    .quote-total-price {
        font-size: 1.35rem;
    }

    /* ---- Checkout: single column already, improve padding ---- */
    .checkout-grid {
        grid-template-columns: 1fr;
        gap: 1.25rem;
    }

    .order-summary-card {
        position: static !important;
    }

    /* ---- Footer: single column ---- */
    .footer-container {
        grid-template-columns: 1fr;
        gap: 1.75rem;
    }

    .footer-bottom-content {
        flex-direction: column;
        text-align: center;
        gap: 0.5rem;
    }

    /* ---- Toast: full-width at bottom ---- */
    .toast-container {
        bottom: 12px;
        right: 1rem;
        left: 1rem;
        width: calc(100% - 2rem);
    }

    .toast {
        font-size: 0.85rem;
        padding: 0.75rem 1rem;
    }

    /* ---- Section padding: tighter on mobile ---- */
    .page-section {
        padding: 2rem 0;
    }

    .auth-hero-section {
        padding: 2.5rem 0 3rem 0;
    }

    /* ---- Testimonials: single column ---- */
    .testimonials-slider,
    .designer-showcase-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    /* ---- Stats banner: smaller on mobile ---- */
    .stats-banner-section {
        border-radius: var(--radius-lg);
        padding: 2rem 1rem;
        margin: 1.5rem 0;
    }

    /* ---- Profile modal meta row: stack on tiny viewports ---- */
    #modal-designer-meta-row,
    #modal-partner-meta-row {
        flex-direction: column;
        gap: 0.3rem;
    }

    /* ---- Button groups on mobile ---- */
    .btn-group-row,
    .action-btn-row {
        flex-direction: column;
        width: 100%;
    }

    .btn-group-row .btn,
    .action-btn-row .btn {
        width: 100%;
        justify-content: center;
    }

    /* ---- Table overflow: ensure all data tables scroll ---- */
    .table-scroll-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: var(--radius-sm);
    }

    /* ---- Section tags/badges: prevent overflow ---- */
    .section-tag,
    .badge-wood-pill,
    .badge-pill {
        white-space: normal;
        word-break: break-word;
    }

    /* ---- Execution stage sign-off row: clean responsive stacking on mobile ---- */
    .execution-signoff-row {
        flex-direction: column;
        align-items: stretch !important;
        gap: 1rem !important;
    }

    .execution-signoff-action {
        align-items: flex-start !important;
        margin-left: 0 !important;
        width: 100%;
    }

    .execution-signoff-action > span {
        text-align: left !important;
        max-width: 100% !important;
    }

    .execution-signoff-action .btn,
    .execution-signoff-action .badge-pill {
        width: 100%;
        text-align: center;
        justify-content: center;
    }
}

/* ---- Small phones (≤ 480px) ---- */
@media (max-width: 480px) {
    .directory-card-actions {
        grid-template-columns: 1fr !important;
    }
}

/* ---- Ultra-narrow phones (≤ 390px) ---- */
@media (max-width: 390px) {

    .container {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    .brand-logo {
        font-size: clamp(0.92rem, 4vw, 1.05rem) !important;
        gap: 0.35rem !important;
    }

    .brand-logo-img,
    .brand-logo-icon {
        width: 26px !important;
        height: 26px !important;
    }

    .header-actions {
        gap: 0.3rem !important;
    }

    .theme-toggle-btn,
    .hamburger-btn {
        width: 40px !important;
        height: 40px !important;
        min-width: 40px !important;
        min-height: 40px !important;
    }

    .hero-h1-mobile {
        font-size: clamp(1.65rem, 8vw, 2.1rem) !important;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .auth-card {
        padding: 1.25rem 1rem;
    }

    .dashboard-panel {
        padding: 1rem 0.875rem;
    }

    .btn-lg {
        padding: 0.7rem 1rem;
        font-size: 0.9rem;
    }

    .hero-cta-row .btn {
        width: 100%;
    }

    .hero-cta-row {
        flex-direction: column;
        align-items: stretch;
    }
}

/* ---- Micro phones (≤ 340px) ---- */
@media (max-width: 340px) {
    .container {
        padding-left: 0.5rem !important;
        padding-right: 0.5rem !important;
    }

    .brand-logo {
        font-size: 0.86rem !important;
        gap: 0.25rem !important;
    }

    .brand-logo-img,
    .brand-logo-icon {
        width: 22px !important;
        height: 22px !important;
    }

    .theme-toggle-btn,
    .hamburger-btn {
        width: 36px !important;
        height: 36px !important;
        min-width: 36px !important;
        min-height: 36px !important;
    }
}
