/* ========================================
   MOBILE-FIRST RESPONSIVE DESIGN - FIXED
   SEO-Optimized & Performance-Focused
   ======================================== */

/* ===== ROOT VARIABLES ===== */
:root {
    --mobile-spacing: 16px;
    --touch-target-size: 44px;
    --mobile-font-base: 16px;
    --mobile-line-height: 1.5;
}

/* ===== BASE IMPROVEMENTS (ALL DEVICES) ===== */
html {
    -webkit-text-size-adjust: 100%;
    -moz-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

/* Prevent Horizontal Overflow */
img, video, iframe {
    max-width: 100%;
    height: auto;
}

/* ===== HAMBURGER MENU (MOBILE ONLY) ===== */
.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    z-index: 1001;
    position: relative;
}

.hamburger {
    width: 28px;
    height: 20px;
    position: relative;
    transform: rotate(0deg);
    transition: 0.5s ease-in-out;
}

.hamburger span {
    display: block;
    position: absolute;
    height: 3px;
    width: 100%;
    background: #14284e;
    border-radius: 3px;
    opacity: 1;
    left: 0;
    transform: rotate(0deg);
    transition: 0.25s ease-in-out;
}

.hamburger span:nth-child(1) {
    top: 0px;
}

.hamburger span:nth-child(2) {
    top: 9px;
}

.hamburger span:nth-child(3) {
    top: 18px;
}

.mobile-menu-toggle.active .hamburger span:nth-child(1) {
    top: 9px;
    transform: rotate(135deg);
}

.mobile-menu-toggle.active .hamburger span:nth-child(2) {
    opacity: 0;
    left: -60px;
}

.mobile-menu-toggle.active .hamburger span:nth-child(3) {
    top: 9px;
    transform: rotate(-135deg);
}

/* ===== MOBILE STYLES (320px - 767px) ===== */
@media screen and (max-width: 767px) {
    
    /* Base Typography */
    body {
        font-size: 16px;
        line-height: 1.5;
    }
    
    /* Header Mobile */
    header {
        display: flex !important;
        flex-direction: row !important;
        justify-content: space-between !important;
        align-items: center !important;
        padding: 12px 16px !important;
        position: sticky !important;
        top: 0 !important;
        z-index: 1000 !important;
        background: white !important;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
    }

    .logo {
        flex: 1 !important;
        text-align: left !important;
        margin-bottom: 0 !important;
    }

    .logo h1 {
        font-size: 1.5rem !important;
        margin: 0 !important;
        line-height: 1.2 !important;
    }

    .logo h2 {
        font-size: 0.75rem !important;
        margin: 0 !important;
        display: none !important;
    }

    /* Show Mobile Menu Toggle */
    .mobile-menu-toggle {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        min-width: 48px !important;
        min-height: 48px !important;
    }

    /* Navigation Mobile */
    header nav {
        position: fixed !important;
        top: 60px !important;
        left: 0 !important;
        right: 0 !important;
        background: white !important;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
        max-height: 0 !important;
        overflow: hidden !important;
        transition: max-height 0.3s ease-in-out, opacity 0.3s ease !important;
        opacity: 0 !important;
        z-index: 999 !important;
        margin-top: 0 !important;
    }

    header nav.active {
        max-height: 500px !important;
        opacity: 1 !important;
    }

    header nav ul {
        display: flex !important;
        flex-direction: column !important;
        padding: 16px !important;
        gap: 0 !important;
        margin: 0 !important;
    }

    header nav ul li {
        width: 100% !important;
        border-bottom: 1px solid #eee !important;
        margin: 0 !important;
    }

    header nav ul li:last-child {
        border-bottom: none !important;
    }

    header nav ul li a {
        display: block !important;
        padding: 16px !important;
        font-size: 1.0625rem !important;
        min-height: 44px !important;
        text-align: left !important;
        width: 100% !important;
    }

    /* Hero Sections Mobile */
    .car-type-hero,
    .brand-hero {
        min-height: 250px !important;
        height: 250px !important;
        padding: 2rem 1rem !important;
    }

    .car-type-hero h1,
    .brand-hero h1 {
        font-size: 2rem !important;
        line-height: 1.2 !important;
        text-align: center !important;
    }

    .brand-tagline {
        font-size: 1rem !important;
    }

    .brand-founded {
        font-size: 0.875rem !important;
    }

    /* Breadcrumb Mobile */
    .breadcrumb-nav,
    .breadcrumb {
        padding: 12px 16px !important;
        font-size: 0.875rem !important;
        overflow-x: auto !important;
        white-space: nowrap !important;
        -webkit-overflow-scrolling: touch !important;
    }

    /* Stats Grid Mobile */
    .brand-quick-stats {
        padding: 1.5rem 16px !important;
    }

    .stats-container {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px !important;
    }

    .stat-box {
        padding: 1rem !important;
        min-height: 80px !important;
    }

    .stat-number {
        font-size: 1.5rem !important;
    }

    .stat-label {
        font-size: 0.75rem !important;
    }

    /* Content Sections Mobile */
    .brand-content-wrapper,
    .car-type-content {
        padding: 16px !important;
    }

    .brand-section,
    .car-type-info-section {
        padding: 1.5rem 16px !important;
        margin-bottom: 1.5rem !important;
    }

    .brand-section h2,
    .info-title {
        font-size: 1.5rem !important;
        margin-bottom: 1rem !important;
    }

    .brand-section h3 {
        font-size: 1.25rem !important;
    }

    .brand-section p,
    .info-text {
        font-size: 1rem !important;
        line-height: 1.6 !important;
        margin-bottom: 1rem !important;
    }

    /* Values Grid Mobile */
    .brand-values-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }

    .value-card {
        padding: 1.25rem !important;
    }

    .value-icon {
        font-size: 2rem !important;
    }

    .value-card h4 {
        font-size: 1.125rem !important;
    }

    /* Models Grid Mobile */
    .models-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }

    .model-category-card {
        padding: 1.25rem !important;
    }

    .model-category-card h3 {
        font-size: 1.125rem !important;
    }

    .model-category-card ul li {
        font-size: 0.9375rem !important;
        padding: 8px 0 !important;
    }

    /* Tech Grid Mobile */
    .tech-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }

    .tech-item {
        padding: 1.25rem !important;
    }

    .tech-item h4 {
        font-size: 1.0625rem !important;
    }

    /* Awards Grid Mobile */
    .awards-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px !important;
    }

    .award-badge {
        padding: 1rem !important;
    }

    .award-icon {
        font-size: 1.75rem !important;
    }

    .award-title {
        font-size: 0.875rem !important;
    }

    .award-year {
        font-size: 0.75rem !important;
    }

    /* Tab Navigation Mobile */
    .tab-navigation {
        display: flex !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        gap: 8px !important;
        padding: 16px !important;
        border-bottom: 2px solid #eee !important;
        white-space: nowrap !important;
        scrollbar-width: none !important;
        -ms-overflow-style: none !important;
    }

    .tab-navigation::-webkit-scrollbar {
        display: none !important;
    }

    .tab-button {
        flex-shrink: 0 !important;
        padding: 12px 20px !important;
        font-size: 0.9375rem !important;
        min-height: 44px !important;
        white-space: nowrap !important;
    }

    /* Gallery Mobile */
    .car-gallery {
        padding: 1.5rem 16px !important;
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }

    .gallery-item {
        margin-bottom: 1rem !important;
    }

    .gallery-caption {
        font-size: 0.875rem !important;
        padding: 8px !important;
    }

    /* Cards Grid Mobile */
    .car-cards,
    .brand-cards,
    .car-type-cards {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
        padding: 16px !important;
    }

    .card {
        padding: 1.25rem !important;
        min-height: auto !important;
    }

    .card h3 {
        font-size: 1.125rem !important;
    }

    .card img {
        height: 180px !important;
    }

    /* Buttons Mobile */
    .learn-more-btn,
    .btn,
    .brand-btn {
        width: 100% !important;
        padding: 14px 20px !important;
        font-size: 1rem !important;
        min-height: 44px !important;
        text-align: center !important;
    }

    /* Footer Mobile */
    footer {
        padding: 1.5rem 16px !important;
        text-align: center !important;
    }

    footer p {
        font-size: 0.875rem !important;
    }

    /* Forms Mobile */
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    input[type="search"],
    select,
    textarea {
        font-size: 16px !important;
        min-height: 44px !important;
        padding: 12px 16px !important;
        width: 100% !important;
        border-radius: 8px !important;
    }

    /* Spacing Mobile */
    .container {
        padding-left: 16px !important;
        padding-right: 16px !important;
    }

    .section {
        padding: 1.5rem 16px !important;
        margin-bottom: 1rem !important;
    }

    /* Table Responsive */
    table {
        display: block !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        white-space: nowrap !important;
    }
}

/* ===== SMALL MOBILE (320px - 480px) ===== */
@media screen and (max-width: 480px) {
    
    .logo h1 {
        font-size: 1.25rem !important;
    }

    .car-type-hero h1,
    .brand-hero h1 {
        font-size: 1.75rem !important;
    }

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

    .awards-grid {
        grid-template-columns: 1fr !important;
    }

    .tab-button {
        padding: 10px 16px !important;
        font-size: 0.875rem !important;
    }
}

/* ===== TABLET (768px - 1023px) ===== */
@media screen and (min-width: 768px) and (max-width: 1023px) {
    
    /* Hide mobile toggle */
    .mobile-menu-toggle {
        display: none !important;
    }

    /* Normal navigation */
    header nav {
        position: static !important;
        max-height: none !important;
        opacity: 1 !important;
        box-shadow: none !important;
    }

    header nav ul {
        flex-direction: row !important;
        gap: 16px !important;
    }

    header nav ul li {
        width: auto !important;
        border-bottom: none !important;
    }

    /* Hero Tablet */
    .car-type-hero,
    .brand-hero {
        min-height: 350px !important;
        height: 350px !important;
    }

    .car-type-hero h1,
    .brand-hero h1 {
        font-size: 2.5rem !important;
    }

    /* Grids Tablet */
    .stats-container {
        grid-template-columns: repeat(4, 1fr) !important;
    }

    .brand-values-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .models-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .tech-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .awards-grid {
        grid-template-columns: repeat(3, 1fr) !important;
    }

    .car-cards,
    .brand-cards,
    .car-type-cards {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .car-gallery {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* Buttons Auto Width */
    .learn-more-btn,
    .btn {
        width: auto !important;
    }
}

/* ===== DESKTOP (1024px+) ===== */
@media screen and (min-width: 1024px) {
    
    /* Hide mobile toggle */
    .mobile-menu-toggle {
        display: none !important;
    }

    /* Full Desktop Styles */
    .car-type-hero,
    .brand-hero {
        min-height: 450px !important;
        height: 450px !important;
    }

    .brand-values-grid {
        grid-template-columns: repeat(3, 1fr) !important;
    }

    .models-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .tech-grid {
        grid-template-columns: repeat(3, 1fr) !important;
    }

    .awards-grid {
        grid-template-columns: repeat(3, 1fr) !important;
    }

    .car-cards,
    .brand-cards,
    .car-type-cards {
        grid-template-columns: repeat(3, 1fr) !important;
    }

    .car-gallery {
        grid-template-columns: repeat(3, 1fr) !important;
    }
}

/* ===== LARGE DESKTOP (1440px+) ===== */
@media screen and (min-width: 1440px) {
    
    .container {
        max-width: 1400px !important;
        margin: 0 auto !important;
    }

    .car-cards,
    .brand-cards,
    .car-type-cards {
        grid-template-columns: repeat(4, 1fr) !important;
    }
}

/* ===== ACCESSIBILITY ===== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

*:focus-visible {
    outline: 3px solid #3a7bd5 !important;
    outline-offset: 2px !important;
}

html {
    scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto !important;
    }
}

/* ===== PRINT ===== */
@media print {
    .mobile-menu-toggle,
    header nav,
    footer,
    .breadcrumb-nav,
    .breadcrumb {
        display: none !important;
    }
    
    body {
        font-size: 12pt !important;
        line-height: 1.5 !important;
    }
}
