/* ==========================================================================
   Aviation Parts Portal - Master Responsive Stylesheet
   Full multi-breakpoint coverage for Mobile, Tablet, Laptop, Desktop, and 4K Displays
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. GLOBAL OVERFLOW & BASE RESPONSIVE RULES
   -------------------------------------------------------------------------- */
*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    width: 100%;
    max-width: 100%;
    overflow-x: clip;
    margin: 0;
    padding: 0;
    -webkit-text-size-adjust: 100%;
}

img, video, iframe, svg, canvas {
    max-width: 100%;
    height: auto;
}

/* Base Mobile Elements State on Desktop */
.mobile-bottom-nav {
    display: none;
}

.mobile-header-controls {
    display: none;
}

.mobile-nav-backdrop,
.mobile-nav-drawer {
    display: none;
}

/* --------------------------------------------------------------------------
   2. DESKTOP & LAPTOP HEADER FLUIDITY (992px - 1440px+)
   -------------------------------------------------------------------------- */
.main-brand-logo-img,
.global-brand-logo-img {
    height: 64px;
    width: auto;
    max-width: 220px;
    object-fit: contain;
    display: block;
    transition: height 0.25s ease;
}

.hdr-lang-icon-img,
.hdr-action-icon-img {
    height: 22px;
    width: 22px;
    object-fit: contain;
    display: block;
}

.desktop-only-nav {
    display: flex;
    align-items: center;
}

.desktop-only-actions {
    display: flex;
    align-items: center;
}

.desktop-only-logout-form {
    display: inline-flex;
    align-items: center;
    margin: 0;
}

/* Badge for Cart count in headers */
.hdr-cart-count-badge {
    position: absolute;
    top: -7px;
    right: -8px;
    background: #c8102e;
    color: #ffffff;
    font-size: 0.68rem;
    font-weight: 800;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 5px rgba(200, 16, 46, 0.4);
}

/* Large Desktop (>= 1200px) */
@media (min-width: 1200px) {
    .site-header-v2 .header-container {
        padding: 0 28px;
    }
    .nav-links {
        gap: 28px;
    }
    .header-actions {
        gap: 16px;
    }
}

/* Intermediate Laptop / Small Desktop (992px - 1199px) */
@media (max-width: 1199px) and (min-width: 992px) {
    .site-header-v2 {
        height: 76px;
        min-height: 76px;
    }

    .main-brand-logo-img,
    .global-brand-logo-img {
        height: 52px;
    }

    .nav-links {
        gap: 16px;
    }

    .nav-links a,
    .nav-logout-btn {
        font-size: 0.8rem;
        letter-spacing: 0.4px;
    }

    .header-actions {
        gap: 10px;
        margin-left: 10px;
    }

    .header-auth-btn {
        font-size: 0.8rem;
        padding: 4px 2px;
    }

    .btn-quote {
        height: 38px;
        padding: 0 14px;
        font-size: 0.78rem;
        letter-spacing: 0.4px;
    }

    .global-header-left {
        gap: 16px !important;
    }

    .global-nav-links {
        gap: 14px !important;
    }

    .global-nav-links a {
        font-size: 0.82rem !important;
    }
}

/* --------------------------------------------------------------------------
   3. TABLET & MOBILE RESPONSIVE HEADER (< 992px)
   -------------------------------------------------------------------------- */
@media (max-width: 991px) {
    /* Hide Desktop Navigation & Actions */
    .desktop-only-nav,
    .desktop-only-actions,
    .desktop-only-logout-form {
        display: none !important;
    }

    /* Header Bar Sizing */
    .site-header-v2 {
        height: 68px !important;
        min-height: 68px !important;
        padding: 0 14px !important;
        position: sticky;
        top: 0;
        z-index: 1000;
        background: #ffffff !important;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
    }

    .header-container,
    .global-header-container {
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        width: 100% !important;
        max-width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    /* Scaled Brand Logo */
    .brand-logo,
    .global-header-brand {
        display: flex;
        align-items: center;
        flex-shrink: 0;
    }

    .main-brand-logo-img,
    .global-brand-logo-img {
        height: 48px !important;
        max-height: 48px !important;
        width: auto !important;
    }

    /* Mobile Controls Row (Quick Action + Hamburger) */
    .mobile-header-controls {
        display: flex !important;
        align-items: center !important;
        gap: 10px !important;
    }

    .global-header-right {
        display: flex !important;
        align-items: center !important;
        gap: 10px !important;
    }

    .mobile-quick-lang {
        display: inline-flex !important;
    }

    /* Mobile Hamburger Button */
    .mobile-hamburger-btn {
        width: 42px;
        height: 42px;
        background: #f8fafc;
        border: 1px solid #e2e8f0;
        border-radius: 8px;
        display: inline-flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 5px;
        cursor: pointer;
        padding: 0;
        outline: none;
        transition: all 0.2s ease;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    }

    .mobile-hamburger-btn:hover,
    .mobile-hamburger-btn:active,
    .mobile-hamburger-btn.active {
        background: #fff5f5;
        border-color: #fca5a5;
    }

    .hamburger-bar {
        width: 20px;
        height: 2px;
        background-color: #0f172a;
        border-radius: 2px;
        transition: all 0.25s ease;
    }

    .mobile-hamburger-btn:hover .hamburger-bar,
    .mobile-hamburger-btn.active .hamburger-bar {
        background-color: #c8102e;
    }

    .mobile-hamburger-btn.active .hamburger-bar:nth-child(1) {
        transform: translateY(7px) rotate(45deg);
    }

    .mobile-hamburger-btn.active .hamburger-bar:nth-child(2) {
        opacity: 0;
    }

    .mobile-hamburger-btn.active .hamburger-bar:nth-child(3) {
        transform: translateY(-7px) rotate(-45deg);
    }

    /* --------------------------------------------------------------------------
       MOBILE NAVIGATION DRAWER & ACCORDION
       -------------------------------------------------------------------------- */
    .mobile-nav-backdrop {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100vw;
        height: 100vh;
        background: rgba(15, 23, 42, 0.6);
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
        z-index: 9998;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease, visibility 0.3s ease;
    }

    .mobile-nav-backdrop.open {
        opacity: 1;
        visibility: visible;
    }

    .mobile-nav-drawer {
        display: flex;
        flex-direction: column;
        position: fixed;
        top: 0;
        right: -320px;
        width: 300px;
        max-width: 85vw;
        height: 100%;
        background: #ffffff;
        z-index: 9999;
        box-shadow: -6px 0 25px rgba(0, 0, 0, 0.18);
        transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        box-sizing: border-box;
    }

    .mobile-nav-drawer.open {
        transform: translateX(-320px);
    }

    body.mobile-drawer-locked {
        overflow: hidden !important;
    }

    /* Drawer Header */
    .mobile-drawer-head {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 16px 20px;
        border-bottom: 1px solid #e2e8f0;
        background: #ffffff;
        position: sticky;
        top: 0;
        z-index: 2;
    }

    .mobile-drawer-brand img {
        height: 44px;
        width: auto;
        object-fit: contain;
        display: block;
    }

    .mobile-drawer-close {
        width: 36px;
        height: 36px;
        background: #f1f5f9;
        border: 1px solid #cbd5e1;
        border-radius: 8px;
        font-size: 1.4rem;
        line-height: 1;
        color: #475569;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        transition: all 0.2s ease;
        outline: none;
        padding: 0;
    }

    .mobile-drawer-close:hover {
        background: #dc2626;
        border-color: #dc2626;
        color: #ffffff;
        transform: rotate(90deg);
    }

    /* Drawer Body */
    .mobile-drawer-body {
        padding: 16px 18px;
        display: flex;
        flex-direction: column;
        flex: 1;
    }

    .mobile-drawer-menu {
        list-style: none;
        padding: 0;
        margin: 0 0 20px 0;
        display: flex;
        flex-direction: column;
        gap: 6px;
    }

    .mobile-nav-link {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 11px 14px;
        border-radius: 8px;
        font-family: var(--font-body, 'Inter', sans-serif);
        font-size: 0.92rem;
        font-weight: 700;
        color: #1e293b;
        text-decoration: none;
        transition: all 0.2s ease;
        background: transparent;
    }

    .mobile-nav-link i {
        width: 20px;
        text-align: center;
        color: #64748b;
        font-size: 1rem;
        transition: color 0.2s ease;
    }

    .mobile-nav-link:hover,
    .mobile-nav-link.active {
        background: #fff5f5;
        color: #c8102e;
    }

    .mobile-nav-link:hover i,
    .mobile-nav-link.active i {
        color: #c8102e;
    }

    /* Drawer Accordion for About Us Submenu */
    .mobile-accordion-item {
        border-radius: 8px;
        overflow: hidden;
    }

    .mobile-accordion-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 11px 14px;
        border-radius: 8px;
        font-family: var(--font-body, 'Inter', sans-serif);
        font-size: 0.92rem;
        font-weight: 700;
        color: #1e293b;
        cursor: pointer;
        transition: all 0.2s ease;
        user-select: none;
    }

    .mobile-accordion-header .mobile-nav-link-text {
        display: flex;
        align-items: center;
        gap: 12px;
    }

    .mobile-accordion-header .mobile-nav-link-text i {
        width: 20px;
        text-align: center;
        color: #64748b;
        font-size: 1rem;
    }

    .mobile-accordion-arrow {
        font-size: 0.78rem;
        color: #94a3b8;
        transition: transform 0.25s ease;
    }

    .mobile-accordion-item.expanded .mobile-accordion-arrow {
        transform: rotate(180deg);
        color: #c8102e;
    }

    .mobile-accordion-item.expanded .mobile-accordion-header,
    .mobile-accordion-header:hover {
        background: #fff5f5;
        color: #c8102e;
    }

    .mobile-accordion-item.expanded .mobile-accordion-header i {
        color: #c8102e;
    }

    .mobile-accordion-body {
        list-style: none;
        padding: 4px 0 6px 32px;
        margin: 0;
        display: none;
        flex-direction: column;
        gap: 4px;
    }

    .mobile-accordion-item.expanded .mobile-accordion-body {
        display: flex;
    }

    .mobile-sub-link {
        display: block;
        padding: 8px 12px;
        font-size: 0.85rem;
        font-weight: 600;
        color: #475569;
        text-decoration: none;
        border-radius: 6px;
        transition: all 0.2s ease;
    }

    .mobile-sub-link:hover,
    .mobile-sub-link.active {
        color: #c8102e;
        background: #f8fafc;
    }

    /* Mobile Drawer Actions */
    .mobile-drawer-actions {
        margin-top: auto;
        padding-top: 16px;
        border-top: 1px solid #e2e8f0;
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    .mobile-drawer-quote-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        width: 100%;
        height: 44px;
        background: #ffffff;
        color: #0f172a;
        border: 1.5px solid #cbd5e1;
        border-radius: 8px;
        font-family: var(--font-heading, 'Outfit', sans-serif);
        font-size: 0.85rem;
        font-weight: 800;
        letter-spacing: 0.5px;
        text-transform: uppercase;
        text-decoration: none;
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.04);
        transition: all 0.2s ease;
    }

    .mobile-drawer-quote-btn:hover,
    .mobile-drawer-quote-btn:active {
        background: #c8102e;
        color: #ffffff;
        border-color: #c8102e;
    }

    .mobile-drawer-auth-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .mobile-drawer-login-btn,
    .mobile-drawer-register-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
        height: 40px;
        border-radius: 8px;
        font-size: 0.85rem;
        font-weight: 700;
        text-decoration: none;
        transition: all 0.2s ease;
    }

    .mobile-drawer-login-btn {
        background: #f1f5f9;
        color: #0f172a;
        border: 1px solid #cbd5e1;
    }

    .mobile-drawer-login-btn:hover,
    .mobile-drawer-login-btn.active {
        background: #c8102e;
        color: #ffffff;
        border-color: #c8102e;
    }

    .mobile-drawer-register-btn {
        background: #002147;
        color: #ffffff;
        border: 1px solid #002147;
    }

    .mobile-drawer-register-btn:hover,
    .mobile-drawer-register-btn.active {
        background: #c8102e;
        border-color: #c8102e;
    }

    .mobile-drawer-logout-form {
        width: 100%;
        margin: 0;
    }

    .mobile-drawer-logout-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        width: 100%;
        height: 42px;
        background: #fef2f2;
        color: #dc2626;
        border: 1px solid #fecaca;
        border-radius: 8px;
        font-size: 0.88rem;
        font-weight: 700;
        cursor: pointer;
        transition: all 0.2s ease;
    }

    .mobile-drawer-logout-btn:hover {
        background: #dc2626;
        color: #ffffff;
    }

    .mobile-drawer-badge {
        background: #c8102e;
        color: #ffffff;
        font-size: 0.72rem;
        font-weight: 800;
        padding: 2px 7px;
        border-radius: 10px;
    }
}

/* --------------------------------------------------------------------------
   4. MOBILE BOTTOM NAVIGATION & SAFE AREAS
   -------------------------------------------------------------------------- */
@media (max-width: 900px) {
    /* Show App-Like Bottom Navigation */
    .mobile-bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        background: #ffffff;
        box-shadow: 0 -3px 12px rgba(15, 23, 42, 0.08);
        z-index: 2000;
        height: 60px;
        height: calc(60px + env(safe-area-inset-bottom, 0px));
        padding-bottom: env(safe-area-inset-bottom, 0px);
        justify-content: space-around;
        align-items: center;
        border-top: 1px solid #e2e8f0;
        box-sizing: border-box;
    }

    .mobile-bottom-nav .nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        color: #64748b;
        font-size: 0.7rem;
        font-weight: 600;
        text-decoration: none;
        flex: 1;
        width: 20%;
        height: 100%;
        margin: 0;
        padding: 4px 0;
        transition: all 0.2s ease;
    }

    .mobile-bottom-nav .nav-item i {
        font-size: 1.15rem;
        margin-bottom: 3px;
        color: #64748b;
        transition: all 0.2s ease;
    }

    .mobile-bottom-nav .nav-item:hover,
    .mobile-bottom-nav .nav-item.active {
        color: #c8102e;
    }

    .mobile-bottom-nav .nav-item:hover i,
    .mobile-bottom-nav .nav-item.active i {
        color: #c8102e;
        transform: translateY(-2px);
    }

    /* Body Padding for Fixed Bottom Navigation */
    body {
        padding-bottom: 68px !important;
        padding-bottom: calc(68px + env(safe-area-inset-bottom, 0px)) !important;
    }

    main[role="main"] {
        padding-bottom: 20px;
    }

    /* Scroll to top button position on mobile */
    .scroll-to-top-btn {
        bottom: 75px !important;
        bottom: calc(75px + env(safe-area-inset-bottom, 0px)) !important;
        right: 15px !important;
        width: 38px !important;
        height: 38px !important;
        font-size: 0.85rem !important;
        z-index: 1999 !important;
    }

    .container {
        padding: 0 14px;
        width: 100% !important;
        max-width: 100% !important;
    }
}

/* --------------------------------------------------------------------------
   5. CATALOG, PRODUCTS & GRID RESPONSIVENESS
   -------------------------------------------------------------------------- */
@media (max-width: 991px) {
    .catalog-layout {
        flex-direction: column !important;
    }

    .catalog-sidebar-panel,
    .catalog-layout.sidebar-collapsed .catalog-sidebar-panel {
        display: flex !important;
        flex-direction: column !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        bottom: 0 !important;
        width: 290px !important;
        max-width: 85vw !important;
        max-height: none !important;
        height: 100vh !important;
        height: 100dvh !important;
        z-index: 10001 !important;
        transform: translateX(-100%) !important;
        transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
        border-radius: 0 !important;
        box-shadow: 10px 0 30px rgba(0, 0, 0, 0.2) !important;
        background: #ffffff !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }

    .catalog-sidebar-panel.open,
    .catalog-layout.sidebar-collapsed .catalog-sidebar-panel.open {
        transform: translateX(0) !important;
    }

    .btn-close-mobile-sidebar {
        display: block !important;
    }

    .sidebar-mobile-backdrop {
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.6);
        backdrop-filter: blur(3px);
        z-index: 10000;
        display: none;
    }

    .sidebar-mobile-backdrop.active {
        display: block;
    }
}

@media (max-width: 768px) {
    /* Parts Catalog 2-Column Responsive Card Grid */
    .part-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
        width: 100% !important;
    }

    .part-card {
        border-radius: 0px !important;
        border: 1px solid #cbd5e1 !important;
    }

    .part-image {
        height: 120px !important;
        padding: 6px !important;
    }

    .part-info {
        padding: 8px 8px !important;
        gap: 4px !important;
    }

    .part-name {
        font-size: 11.5px !important;
        font-weight: 700 !important;
        line-height: 1.3 !important;
        height: 2.6em !important;
        min-height: 2.6em !important;
        word-break: normal !important;
        overflow-wrap: break-word !important;
    }

    .part-actions {
        height: 40px !important;
        min-height: 40px !important;
    }

    .part-actions button {
        height: 40px !important;
        min-height: 40px !important;
        font-size: 11px !important;
        font-weight: 700 !important;
    }

    .category-section {
        margin-bottom: 26px !important;
    }

    .category-section-header {
        padding: 6px 0 8px 0 !important;
        margin-bottom: 12px !important;
    }

    /* Product Details Page */
    .product-details-grid {
        display: flex !important;
        flex-direction: column !important;
        gap: 16px !important;
    }

    .details-col-left,
    .details-col-center,
    .details-col-right {
        width: 100% !important;
    }

    /* Cart Page */
    .cart-layout {
        display: flex !important;
        flex-direction: column !important;
        gap: 16px !important;
    }

    .cart-item-row {
        flex-direction: row !important;
        padding: 10px !important;
        gap: 12px !important;
    }

    .summary-box {
        position: static !important;
        width: 100% !important;
    }

    /* Generic Tables Overflow Protection */
    table:not(.specs-table) {
        display: block !important;
        width: 100% !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        white-space: nowrap !important;
    }
}

/* --------------------------------------------------------------------------
   6. SMALL MOBILE SCREENS (< 480px)
   -------------------------------------------------------------------------- */
@media (max-width: 480px) {
    .site-header-v2 {
        height: 60px !important;
        min-height: 60px !important;
        padding: 0 10px !important;
    }

    .main-brand-logo-img,
    .global-brand-logo-img {
        height: 40px !important;
        max-height: 40px !important;
    }

    .mobile-hamburger-btn {
        width: 36px;
        height: 36px;
    }

    .hamburger-bar {
        width: 18px;
    }

    .container {
        padding: 0 10px;
    }

    /* Modal responsiveness */
    .modal-content,
    .cert-modal-dialog {
        width: 95% !important;
        margin: 0 auto !important;
        max-height: 92vh !important;
    }
}