/* 
   Apex Woodworks - Mobile & Responsive Styles
   Load this AFTER styles.css to override desktop styles.
*/

/* Global Fixes */
html,
body {
    overflow-x: hidden;
    max-width: 100vw;
    background-color: var(--bg-body);
}

@media (max-width: 768px) {

    html,
    body {
        background-color: #0f0f0f;
        /* Matches footer bottom color to hide any potential gaps */
    }

    body> :not(footer) {
        background-color: var(--bg-body);
        /* Keep main content white */
    }
}

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

/* =========================================
   TABLET & SMALL LAPTOPS (max-width: 992px)
   ========================================= */
@media (max-width: 992px) {

    /* Hide Top Bar on Mobile */
    .top-bar {
        display: none !important;
    }

    /* Category Menu Horizontal Scroll */
    .cat-menu {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        justify-content: flex-start !important;
        padding: 10px 0;
        gap: 15px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        margin-bottom: 0;
        width: 100%;
    }

    .cat-menu::-webkit-scrollbar {
        display: none;
    }

    .cat-menu li {
        flex: 0 0 auto !important;
        width: auto !important;
        margin-bottom: 0;
    }

    .cat-menu a {
        padding: 8px 15px;
        white-space: nowrap;
        background: #f8f9fa;
        border-radius: 20px;
        border: 1px solid #eee;
        display: flex;
        align-items: center;
        gap: 5px;
    }

    /* Fix Infinite Height Issue */
    .product-groups-layout,
    .product-groups-layout.reversed {
        display: flex !important;
        flex-direction: column !important;
        grid-template-columns: none !important;
        height: auto !important;
    }

    .product-groups-left,
    .product-groups-right {
        width: 100% !important;
        height: auto !important;
        order: unset !important;
    }

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

    /* --- Navigation --- */
    /* header-nav hidden rule removed to allow toggling via JS */

    .mobile-menu-toggle {
        display: flex;
        margin-right: 5px;
        /* Show hamburger icon */
    }

    .logo {
        margin-left: 5px;
    }

    /* --- Hero Slider --- */
    .hero-slider-section {
        height: auto;
        min-height: 600px;
        padding: 100px 0 60px;
    }

    .slide-container {
        flex-direction: column;
        justify-content: center;
        text-align: center;
        gap: 3rem;
    }

    .slide-content-left {
        padding: 0;
        order: 1;
    }

    .slide-visual-right {
        order: 2;
        width: 80%;
        margin: 0 auto;
        height: 300px;
        display: none;
        /* Simplify for cleaner mobile look */
    }

    .slide-title {
        font-size: 3rem;
    }

    /* --- Footer --- */
    .footer-bottom-content {
        grid-template-columns: 1fr;
        justify-items: center;
        text-align: center;
        gap: 1.5rem;
    }

    .footer-bottom-content p.copyright,
    .developer-credit {
        justify-self: center;
        text-align: center;
    }
}

/* =========================================
   MOBILE PHONES (max-width: 768px)
   ========================================= */
@media (max-width: 768px) {

    /* --- Typography Scaling --- */
    html {
        font-size: 14px;
    }

    h1 {
        font-size: 2.2rem !important;
    }

    /* --- Slider Fixes (Minimal & Compact) --- */
    .hero-slider-section {
        min-height: auto !important;
        /* Remove 600px restriction */
        height: auto !important;
        padding: 0 !important;
        /* Remove padding to eliminate gaps */
    }

    .slide-subtitle {
        font-size: 0.85rem !important;
        /* Minimal look */
        letter-spacing: 2px !important;
        font-weight: 600 !important;
        margin-bottom: 5px !important;
        display: block;
    }

    .slide-title {
        font-size: 1.8rem !important;
        line-height: 1.2 !important;
        margin-bottom: 10px !important;
    }

    .slide-desc {
        font-size: 0.9rem !important;
        margin-bottom: 20px !important;
        max-width: 90%;
        margin-left: auto;
        margin-right: auto;
    }

    .hero-swiper {
        height: auto !important;
        min-height: auto !important;
        /* Ensure it wraps tightly around content */
    }

    /* Minimal Slider Button */
    .hero-slider-section .btn,
    .hero-slider-section .btn-hero {
        padding: 8px 20px !important;
        font-size: 0.8rem !important;
        font-weight: 600 !important;
        text-transform: uppercase;
        letter-spacing: 1px;
        min-width: auto !important;
        height: auto !important;
        margin-top: 10px !important;
        line-height: normal !important;
        border-radius: 4px;
        /* Optional slight roundness */
    }

    h2 {
        font-size: 1.8rem !important;
    }

    h3 {
        font-size: 1.4rem !important;
    }

    p {
        font-size: 1rem !important;
    }

    /* --- General Layout --- */
    .section-padding {
        padding: 4rem 0;
    }

    .slider-intro-section {
        padding-top: 1rem !important;
        /* Reduce gap below slider */
    }

    /* --- Header --- */
    .header-content {
        padding: 10px 0;
    }

    /* Logo - Force Size */
    header .logo img,
    .header-mobile .logo img,
    .header-premium .logo img,
    .logo img {
        height: 60px !important;
        max-height: 60px !important;
        width: auto !important;
        object-fit: contain;
    }

    /* --- Mobile Header Refinements --- */
    .search-trigger {
        display: none !important;
    }

    /* Restore Compact Language Switcher */
    .language-switcher {
        display: block !important;
        margin-left: 5px;
        margin-right: 5px;
    }

    .language-switcher .lang-btn {
        padding: 5px !important;
        font-size: 0.8rem !important;
        font-weight: 700 !important;
        display: flex;
        align-items: center;
        background: transparent;
        border: none;
    }

    .language-switcher .lang-btn svg {
        display: none !important;
        /* Hide arrow */
    }

    /* Header Actions Layout */
    .header-actions {
        flex: 1;
        display: flex !important;
        justify-content: flex-end !important;
        /* Push items right */
        align-items: center !important;
        margin-left: 10px;
    }

    .btn-premium-cta {
        display: flex !important;
        align-items: center;
        gap: 5px;
        padding: 6px 12px !important;
        font-size: 0.8rem !important;
        background: var(--primary-color, #333);
        color: white !important;
        border-radius: 30px !important;
        width: auto !important;
        height: auto !important;
        text-decoration: none;
        white-space: nowrap;
        order: -1;
        /* Move to first position */
        margin-right: auto !important;
        /* Push adjacent items to far right */
    }

    .btn-premium-cta span {
        display: inline-block !important;
    }

    .btn-premium-cta svg {
        width: 14px !important;
        height: 14px !important;
    }

    /* Mobile Menu Toggle - Force Size */
    .mobile-menu-toggle {
        margin-left: 5px !important;
        padding: 5px !important;
        display: flex !important;
        align-items: center !important;
        color: #333;
        height: auto !important;
        min-height: 40px !important;
        /* Ensure touch target and vertical space */
        width: auto !important;
    }

    .mobile-menu-toggle svg {
        width: 32px !important;
        height: 32px !important;
        stroke-width: 2px !important;
        min-width: 32px !important;
    }



    /* --- Product Grids --- */
    .categories-grid,
    .products-grid,
    .masonry-grid,
    .process-steps {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    /* --- About Page --- */
    .about-hero {
        padding: 6rem 0 4rem;
    }

    .hero-title {
        font-size: 2.5rem !important;
    }

    .hero-stats-inline {
        flex-direction: column;
        gap: 2rem;
    }

    .stat-divider {
        width: 60px;
        height: 2px;
    }

    .split-container {
        grid-template-columns: 1fr;
    }

    .image-stack {
        height: 300px;
        margin-bottom: 2rem;
    }

    .mv-grid-modern {
        grid-template-columns: 1fr;
    }

    /* --- Contact Page --- */
    .contact-split-layout {
        grid-template-columns: 1fr;
    }

    .contact-form-side,
    .contact-info-side {
        width: 100%;
    }

    /* --- Footer (Advanced Layout) --- */
    .footer-grid {
        grid-template-columns: 1fr;
        gap: 2.5rem;
        text-align: center;
    }

    .footer-brand {
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    .footer-social {
        justify-content: center;
    }

    .newsletter-content {
        flex-direction: column;
        text-align: center;
    }

    .newsletter-form {
        flex-direction: column;
        width: 100%;
    }

    .newsletter-form input {
        width: 100%;
        margin-bottom: 1rem;
    }

    .newsletter-form button {
        width: 100%;
        justify-content: center;
    }

    /* --- Services Page --- */
    .stats-minimal {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }

    .process-steps-minimal {
        grid-template-columns: 1fr;
    }

    /* --- Product Detail --- */
    .product-detail-container {
        grid-template-columns: 1fr;
    }

    .detail-gallery {
        margin-bottom: 2rem;
    }

    /* --- Timeline --- */
    .timeline-item-modern {
        flex-direction: column !important;
        padding-left: 3rem;
        align-items: flex-start;
        margin-bottom: 3rem;
    }

    .timeline-dot-modern {
        left: 0;
        transform: none;
    }

    .timeline-line {
        left: 9px;
        transform: none;
    }

    .timeline-content-modern {
        width: 100%;
        text-align: left;
    }
}

/* =========================================
   SMALL MOBILE (max-width: 480px)
   ========================================= */
@media (max-width: 480px) {
    .stats-minimal {
        grid-template-columns: 1fr;
    }

    .cat-menu {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        justify-content: flex-start !important;
        padding-bottom: 15px !important;
        -webkit-overflow-scrolling: touch !important;
        white-space: nowrap !important;
        gap: 10px !important;
    }

    .cat-menu li {
        flex: 0 0 auto !important;
        display: inline-block !important;
    }
}


/* =========================================
   SIDE DRAWER MOBILE MENU
   ========================================= */
.mobile-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    z-index: 9999;
    visibility: hidden;
    transition: visibility 0.5s;
}

.mobile-menu-overlay.active {
    visibility: visible;
}

/* Backdrop */
.mobile-menu-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    opacity: 0;
    transition: opacity 0.5s ease;
}

.mobile-menu-overlay.active .mobile-menu-backdrop {
    opacity: 1;
}

/* Drawer Container */
.mobile-menu-container {
    position: absolute;
    top: 0;
    right: 0;
    width: 85%;
    max-width: 400px;
    height: 100%;
    background-color: white;
    color: #333;
    padding: 2rem 1.5rem;
    /* Reduced padding */
    transform: translateX(100%);
    transition: transform 0.5s cubic-bezier(0.77, 0, 0.175, 1);
    box-shadow: -5px 0 20px rgba(0, 0, 0, 0.1);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.mobile-menu-overlay.active .mobile-menu-container {
    transform: translateX(0);
}

.mobile-menu-close {
    position: absolute;
    top: 15px;
    /* Adjusted position */
    right: 15px;
    background: #f8f9fa;
    border: none;
    color: #333;
    cursor: pointer;
    z-index: 10;
    width: 36px;
    /* Slightly smaller */
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.mobile-menu-close:hover {
    background-color: #e9ecef;
    transform: rotate(90deg);
}

/* Header Row: Logo + Quote Button */
.mobile-menu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    /* Reduced from 1rem */
    padding-right: 40px;
    /* Space for close button */
}

.mobile-logo {
    margin-bottom: 0;
    /* Removed bottom margin */
}

/* Mobile Header */
.header-mobile {
    background: #fff;
    padding: 10px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
}

.header-mobile .logo {
    margin-right: auto;
    /* Push link/button to right */
    display: flex;
    align-items: center;
}

/* Logo */
.header-mobile .logo img {
    height: 60px !important;
    /* Increased from 32px */
    width: auto !important;
    max-width: 180px;
    object-fit: contain;
}

/* Quote Button in Header */
.header-mobile .btn-premium-cta {
    display: inline-flex;
    align-items: center;
    background: #007f5f;
    color: white;
    padding: 8px 16px;
    border-radius: 4px;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
    margin-right: 10px;
}

/* ... menu styles ... */

.btn-mobile-cta {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    padding: 8px 20px !important;
    /* Increased padding */
    background: #007f5f !important;
    color: white !important;
    border-radius: 4px;
    font-size: 0.9rem !important;
    /* Slightly larger */
    font-weight: 700 !important;
    text-decoration: none;
    text-transform: uppercase;
    white-space: nowrap;
    line-height: normal !important;
    width: auto !important;
    height: auto !important;
    min-width: 100px;
    /* Ensure minimum width */
}

/* Language Switcher */
.mobile-lang-switcher {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    /* Space from menu */
    margin-bottom: 0.5rem;
    padding-bottom: 10px;
    border-bottom: 1px solid #e9ecef;
    /* Separator from Contact */
    border-top: 1px solid #e9ecef;
    /* Separator from Menu if needed? Or just rely on menu border */
    justify-content: flex-end !important;
    width: 100%;
}

.mobile-lang-switcher a {
    padding: 6px 10px;
    /* Larger touch target */
    color: #666;
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: 4px;
    transition: all 0.2s;
}

.mobile-lang-switcher a.active {
    background: #007f5f !important;
    color: white !important;
}

/* Navigation */
.mobile-nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
    text-align: right;
    padding-top: 0;
}

.mobile-nav li {
    margin-bottom: 0;
    border-bottom: 1px solid #f8f9fa;
}

.mobile-nav li a {
    display: block;
    padding: 8px 0;
    /* Reduced from 12px */
    font-size: 1.35rem;
    font-weight: 800;
    color: #222;
    text-decoration: none;
    transition: color 0.3s;
    letter-spacing: -0.5px;
    line-height: 1.2;
    /* Tighter line height */
}

.mobile-nav li:last-child {
    border-bottom: none;
}

/* Contact Info */
.mobile-contact-info {
    margin-top: auto;
    padding-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    /* Slightly larger gap for readability */
    align-items: flex-end;
    /* Right align contact info */
    width: 100%;
}

.contact-link {
    display: flex;
    flex-direction: row;
    /* Default row */
    align-items: center;
    color: #555;
    font-size: 0.95rem;
    /* Match menu size */
    font-weight: 500;
    text-decoration: none;
    justify-content: flex-end;
    /* Push content to right */
    width: 100%;
}

.contact-text {
    margin-right: 0;
    margin-left: 8px;
    /* Space from icon */
    text-align: right;
    order: 2;
    /* Text after icon */
}

.contact-icon {
    flex-shrink: 0;
    color: #007f5f;
    order: 1;
    /* Icon before text */
}

/* Stop Body Scroll */
body.no-scroll {
    overflow: hidden !important;
}

.mobile-menu-overlay.active .mobile-nav li {
    opacity: 1;
    transform: translateX(0);
}

.mobile-nav a {
    color: #333;
    text-decoration: none;
    font-size: 1.25rem;
    font-weight: 600;
    font-family: var(--font-heading, 'Outfit', sans-serif);
    display: block;
    width: 100%;
}

.mobile-nav a:hover {
    color: var(--primary-color, #1a237e);
    padding-left: 10px;
    /* Slight movement on hover */
}

.mobile-lang-switcher {
    margin: 2rem 0;
    display: flex;
    justify-content: flex-start;
    gap: 1rem;
    border-top: 1px solid #eee;
    padding-top: 2rem;
}

.mobile-lang-switcher a {
    color: #999;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    padding: 5px 10px;
    border-radius: 4px;
    background: #f8f9fa;
    transition: all 0.3s ease;
}

.mobile-lang-switcher a.active,
.mobile-lang-switcher a:hover {
    color: white;
    background-color: var(--primary-color, #1a237e);
}

.mobile-contact-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
    margin-top: auto;
    /* Push to bottom */
}

.contact-link {
    color: #666;
    text-decoration: none;
    font-size: 1rem;
    font-weight: 500;
}

.btn-mobile-cta {
    background-color: var(--secondary-color, #dc3545);
    color: white;
    padding: 1rem 0;
    width: 100%;
    text-align: center;
    border-radius: 8px;
    /* Less rounded for drawer style */
    text-decoration: none;
    font-weight: 600;
    font-size: 1rem;
    transition: background-color 0.3s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.btn-mobile-cta:hover {
    background-color: #c82333;
    transform: translateY(-2px);
}

/* =========================================
   BREADCRUMB FIX
   ========================================= */
@media (max-width: 768px) {

    .breadcrumb-nav,
    .container.header-content,
    .breadcrumb-container {
        /* Add common variants */
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        align-items: center !important;
        justify-content: flex-start !important;
        gap: 0.5rem !important;
        padding: 10px 0 !important;
    }

    .breadcrumb-nav a,
    .breadcrumb-nav span {
        font-size: 0.85rem !important;
        white-space: nowrap;
    }

    /* Ensure separators display inline */
    .breadcrumb-nav span.separator,
    .breadcrumb-item+.breadcrumb-item::before {
        display: inline-block !important;
        margin: 0 5px;
    }
}

/* =========================================
   HIDE FOOTER MENUS ON MOBILE
   ========================================= */
@media (max-width: 768px) {

    /* Hide the middle columns (Corporate, Resources) */
    .footer-col:nth-child(2),
    .footer-col:nth-child(3) {
        display: none !important;
    }

    /* Ensure other columns stack nicely */
    .footer-grid {
        grid-template-columns: 1fr !important;
        gap: 2rem !important;
    }

    /* Refine Contact Info */
    .footer-contact {
        padding: 0;
        margin-top: 1rem;
    }

    .footer-contact li {
        list-style: none;
        margin-bottom: 12px;
        padding: 15px;
        background-color: rgba(255, 255, 255, 0.05);
        /* Subtle card background */
        border-radius: 12px;
        display: flex;
        align-items: center;
        justify-content: center;
        text-align: center;
        border: 1px solid rgba(255, 255, 255, 0.1);
        transition: transform 0.3s ease;
    }

    .footer-contact li:active {
        transform: scale(0.98);
        background-color: rgba(255, 255, 255, 0.1);
    }

    .footer-contact span {
        font-size: 1rem;
        line-height: 1.5;
        color: rgba(255, 255, 255, 0.9);
    }

    /* Ensure Footer Bottom is visible and spaced */
    .footer-modern,
    .footer-bottom {
        height: auto !important;
        overflow: visible !important;
    }

    .footer-bottom-content {
        margin-top: 2rem !important;
        padding-top: 2rem !important;
        padding-bottom: 3rem !important;
        /* Extra space for mobile bars */
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        gap: 1rem;
        position: relative;
        z-index: 10;
    }

    .footer-bottom-content p.copyright {
        font-size: 0.9rem !important;
        opacity: 0.9 !important;
        /* Increase visibility */
        margin-bottom: 0.5rem;
        color: white !important;
        text-align: center;
    }

    .developer-credit {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
    }

    .developer-credit a {
        display: inline-block;
        padding: 8px 15px;
        background: rgba(255, 255, 255, 0.1);
        border-radius: 6px;
        font-size: 0.85rem !important;
        color: white !important;
        /* Force white text */
        text-decoration: none;
        opacity: 1 !important;
    }
}