/* Advanced Responsive Design System */

/* ===== RESPONSIVE VARIABLES ===== */
:root {
    /* Breakpoints */
    --bp-xs: 480px;
    --bp-sm: 640px;
    --bp-md: 768px;
    --bp-lg: 1024px;
    --bp-xl: 1280px;
    --bp-2xl: 1536px;
    
    /* Container sizes */
    --container-xs: 100%;
    --container-sm: 640px;
    --container-md: 768px;
    --container-lg: 1024px;
    --container-xl: 1280px;
    --container-2xl: 1536px;
    
    /* Spacing scale */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;
    --space-16: 4rem;
    --space-20: 5rem;
    
    /* Font sizes */
    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-base: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.25rem;
    --text-2xl: 1.5rem;
    --text-3xl: 1.875rem;
    --text-4xl: 2.25rem;
    --text-5xl: 3rem;
    --text-6xl: 3.75rem;
    
    /* Touch targets */
    --touch-target: 44px;
    --touch-target-sm: 36px;
    --touch-target-lg: 56px;
}

/* ===== CONTAINER SYSTEM ===== */
.container {
    width: 100%;
    margin-left: auto;
    margin-right: auto;
    padding-left: var(--space-4);
    padding-right: var(--space-4);
}

.container-fluid {
    width: 100%;
    padding-left: var(--space-4);
    padding-right: var(--space-4);
}

/* ===== RESPONSIVE GRID SYSTEM ===== */
.grid {
    display: grid;
    gap: var(--space-4);
}

.grid-cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
.grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-cols-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.grid-cols-12 { grid-template-columns: repeat(12, minmax(0, 1fr)); }

.grid-auto-fit {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.grid-auto-fill {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

/* Column spans */
.col-span-1 { grid-column: span 1 / span 1; }
.col-span-2 { grid-column: span 2 / span 2; }
.col-span-3 { grid-column: span 3 / span 3; }
.col-span-4 { grid-column: span 4 / span 4; }
.col-span-6 { grid-column: span 6 / span 6; }
.col-span-full { grid-column: 1 / -1; }

/* ===== FLEXBOX UTILITIES ===== */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-row { flex-direction: row; }
.flex-wrap { flex-wrap: wrap; }
.flex-nowrap { flex-wrap: nowrap; }

.items-start { align-items: flex-start; }
.items-center { align-items: center; }
.items-end { align-items: flex-end; }
.items-stretch { align-items: stretch; }

.justify-start { justify-content: flex-start; }
.justify-center { justify-content: center; }
.justify-end { justify-content: flex-end; }
.justify-between { justify-content: space-between; }
.justify-around { justify-content: space-around; }
.justify-evenly { justify-content: space-evenly; }

.flex-1 { flex: 1 1 0%; }
.flex-auto { flex: 1 1 auto; }
.flex-initial { flex: 0 1 auto; }
.flex-none { flex: none; }

/* ===== SPACING UTILITIES ===== */
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-5 { gap: var(--space-5); }
.gap-6 { gap: var(--space-6); }
.gap-8 { gap: var(--space-8); }
.gap-10 { gap: var(--space-10); }
.gap-12 { gap: var(--space-12); }

/* Padding */
.p-0 { padding: 0; }
.p-1 { padding: var(--space-1); }
.p-2 { padding: var(--space-2); }
.p-3 { padding: var(--space-3); }
.p-4 { padding: var(--space-4); }
.p-5 { padding: var(--space-5); }
.p-6 { padding: var(--space-6); }
.p-8 { padding: var(--space-8); }
.p-10 { padding: var(--space-10); }
.p-12 { padding: var(--space-12); }

.px-4 { padding-left: var(--space-4); padding-right: var(--space-4); }
.py-4 { padding-top: var(--space-4); padding-bottom: var(--space-4); }

/* Margin */
.m-0 { margin: 0; }
.m-auto { margin: auto; }
.mx-auto { margin-left: auto; margin-right: auto; }
.my-4 { margin-top: var(--space-4); margin-bottom: var(--space-4); }

/* ===== TYPOGRAPHY UTILITIES ===== */
.text-xs { font-size: var(--text-xs); }
.text-sm { font-size: var(--text-sm); }
.text-base { font-size: var(--text-base); }
.text-lg { font-size: var(--text-lg); }
.text-xl { font-size: var(--text-xl); }
.text-2xl { font-size: var(--text-2xl); }
.text-3xl { font-size: var(--text-3xl); }
.text-4xl { font-size: var(--text-4xl); }
.text-5xl { font-size: var(--text-5xl); }

.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.font-light { font-weight: 300; }
.font-normal { font-weight: 400; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

/* ===== VISIBILITY UTILITIES ===== */
.hidden { display: none; }
.block { display: block; }
.inline { display: inline; }
.inline-block { display: inline-block; }

/* ===== MOBILE-FIRST RESPONSIVE BREAKPOINTS ===== */

/* Extra Small devices (phones, 480px and up) */
@media (min-width: 480px) {
    .container { max-width: var(--container-xs); }
    
    /* XS-specific utilities */
    .xs\:block { display: block; }
    .xs\:hidden { display: none; }
    .xs\:flex { display: flex; }
    .xs\:grid { display: grid; }
    
    .xs\:grid-cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
    .xs\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    
    .xs\:text-sm { font-size: var(--text-sm); }
    .xs\:text-base { font-size: var(--text-base); }
    .xs\:text-lg { font-size: var(--text-lg); }
    
    .xs\:p-4 { padding: var(--space-4); }
    .xs\:px-6 { padding-left: var(--space-6); padding-right: var(--space-6); }
}

/* Small devices (tablets, 640px and up) */
@media (min-width: 640px) {
    .container { max-width: var(--container-sm); }
    
    .sm\:block { display: block; }
    .sm\:hidden { display: none; }
    .sm\:flex { display: flex; }
    .sm\:grid { display: grid; }
    
    .sm\:grid-cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
    .sm\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .sm\:grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    
    .sm\:flex-row { flex-direction: row; }
    .sm\:flex-col { flex-direction: column; }
    
    .sm\:text-base { font-size: var(--text-base); }
    .sm\:text-lg { font-size: var(--text-lg); }
    .sm\:text-xl { font-size: var(--text-xl); }
    .sm\:text-2xl { font-size: var(--text-2xl); }
    
    .sm\:p-6 { padding: var(--space-6); }
    .sm\:px-8 { padding-left: var(--space-8); padding-right: var(--space-8); }
    
    .sm\:gap-6 { gap: var(--space-6); }
}

/* Medium devices (tablets, 768px and up) */
@media (min-width: 768px) {
    .container { max-width: var(--container-md); }
    
    .md\:block { display: block; }
    .md\:hidden { display: none; }
    .md\:flex { display: flex; }
    .md\:grid { display: grid; }
    
    .md\:grid-cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
    .md\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .md\:grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .md\:grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    
    .md\:col-span-1 { grid-column: span 1 / span 1; }
    .md\:col-span-2 { grid-column: span 2 / span 2; }
    .md\:col-span-3 { grid-column: span 3 / span 3; }
    
    .md\:flex-row { flex-direction: row; }
    .md\:flex-col { flex-direction: column; }
    
    .md\:text-lg { font-size: var(--text-lg); }
    .md\:text-xl { font-size: var(--text-xl); }
    .md\:text-2xl { font-size: var(--text-2xl); }
    .md\:text-3xl { font-size: var(--text-3xl); }
    
    .md\:p-8 { padding: var(--space-8); }
    .md\:px-10 { padding-left: var(--space-10); padding-right: var(--space-10); }
    
    .md\:gap-8 { gap: var(--space-8); }
}

/* Large devices (desktops, 1024px and up) */
@media (min-width: 1024px) {
    .container { max-width: var(--container-lg); }
    
    .lg\:block { display: block; }
    .lg\:hidden { display: none; }
    .lg\:flex { display: flex; }
    .lg\:grid { display: grid; }
    
    .lg\:grid-cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
    .lg\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .lg\:grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .lg\:grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .lg\:grid-cols-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
    
    .lg\:col-span-1 { grid-column: span 1 / span 1; }
    .lg\:col-span-2 { grid-column: span 2 / span 2; }
    .lg\:col-span-3 { grid-column: span 3 / span 3; }
    .lg\:col-span-4 { grid-column: span 4 / span 4; }
    
    .lg\:flex-row { flex-direction: row; }
    .lg\:items-center { align-items: center; }
    .lg\:justify-between { justify-content: space-between; }
    
    .lg\:text-xl { font-size: var(--text-xl); }
    .lg\:text-2xl { font-size: var(--text-2xl); }
    .lg\:text-3xl { font-size: var(--text-3xl); }
    .lg\:text-4xl { font-size: var(--text-4xl); }
    
    .lg\:p-10 { padding: var(--space-10); }
    .lg\:px-12 { padding-left: var(--space-12); padding-right: var(--space-12); }
    
    .lg\:gap-10 { gap: var(--space-10); }
}

/* Extra large devices (large desktops, 1280px and up) */
@media (min-width: 1280px) {
    .container { max-width: var(--container-xl); }
    
    .xl\:grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .xl\:grid-cols-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
    .xl\:grid-cols-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
    
    .xl\:text-2xl { font-size: var(--text-2xl); }
    .xl\:text-3xl { font-size: var(--text-3xl); }
    .xl\:text-4xl { font-size: var(--text-4xl); }
    .xl\:text-5xl { font-size: var(--text-5xl); }
    
    .xl\:p-12 { padding: var(--space-12); }
    .xl\:gap-12 { gap: var(--space-12); }
}

/* 2X Large devices (larger desktops, 1536px and up) */
@media (min-width: 1536px) {
    .container { max-width: var(--container-2xl); }
    
    .\32xl\:grid-cols-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
    .\32xl\:text-5xl { font-size: var(--text-5xl); }
    .\32xl\:text-6xl { font-size: var(--text-6xl); }
}

/* ===== TOUCH-FRIENDLY DESIGN ===== */
@media (hover: none) and (pointer: coarse) {
    /* Touch devices */
    .btn, button, .glass-button, .action-btn {
        min-height: var(--touch-target);
        min-width: var(--touch-target);
        padding: var(--space-3) var(--space-4);
    }
    
    .btn-sm {
        min-height: var(--touch-target-sm);
        min-width: var(--touch-target-sm);
    }
    
    .btn-lg {
        min-height: var(--touch-target-lg);
        min-width: var(--touch-target-lg);
    }
    
    /* Larger tap targets for navigation */
    .nav-link {
        padding: var(--space-4);
        min-height: var(--touch-target);
    }
    
    /* Larger form controls */
    .form-input, .form-select, .form-textarea {
        min-height: var(--touch-target);
        padding: var(--space-3) var(--space-4);
        font-size: var(--text-base);
    }
    
    /* Increase spacing for touch */
    .card, .modal-content {
        padding: var(--space-6);
    }
    
    .gallery-btn, .action-btn {
        min-width: var(--touch-target);
        min-height: var(--touch-target);
    }
}

/* ===== PRINT STYLES ===== */
@media print {
    .no-print {
        display: none !important;
    }
    
    .print-only {
        display: block !important;
    }
    
    body {
        background: white !important;
        color: black !important;
        font-size: 12pt;
        line-height: 1.4;
    }
    
    .header-glass, .footer-glass, .nav-menu, .gallery-overlay {
        display: none !important;
    }
    
    .container {
        max-width: none !important;
        padding: 0 !important;
    }
    
    a[href^="http"]:after {
        content: " (" attr(href) ")";
        font-size: 10pt;
        color: #666;
    }
}

/* ===== REDUCED MOTION ===== */
@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;
    }
    
    .parallax-layer {
        transform: none !important;
    }
    
    .preserve-3d {
        transform-style: flat !important;
    }
}

/* ===== HIGH CONTRAST MODE ===== */
@media (prefers-contrast: high) {
    :root {
        --primary-color: #000000;
        --secondary-color: #ffffff;
        --accent-color: #0066cc;
    }
    
    .glass-button, .btn {
        border: 2px solid currentColor;
        background: transparent;
    }
    
    .card, .modal-content {
        border: 2px solid currentColor;
        background: white;
        color: black;
    }
}

/* ===== DARK MODE PREFERENCES ===== */
@media (prefers-color-scheme: dark) {
    :root {
        --text-primary: #ffffff;
        --text-secondary: #e5e7eb;
        --bg-primary: #111827;
        --bg-secondary: #1f2937;
    }
}

/* ===== ORIENTATION CHANGES ===== */
@media (orientation: landscape) and (max-height: 500px) {
    /* Landscape mobile optimization */
    .hero-section {
        min-height: 80vh;
        padding: var(--space-4) 0;
    }
    
    .modal-content {
        max-height: 90vh;
        overflow-y: auto;
    }
    
    .gallery-main {
        height: calc(100vh - 120px);
    }
}

/* ===== HOVER CAPABLE DEVICES ===== */
@media (hover: hover) and (pointer: fine) {
    /* Desktop/mouse interactions */
    .hover\:scale-105:hover {
        transform: scale(1.05);
    }
    
    .hover\:opacity-80:hover {
        opacity: 0.8;
    }
    
    .group:hover .group-hover\:opacity-100 {
        opacity: 1;
    }
}

/* ===== COMPONENT-SPECIFIC RESPONSIVE STYLES ===== */

/* Navigation responsive behavior */
.nav-menu {
    display: flex;
    gap: var(--space-6);
}

@media (max-width: 768px) {
    .nav-menu {
        position: fixed;
        top: 0;
        left: -100%;
        width: 80%;
        height: 100vh;
        background: rgba(15, 23, 42, 0.95);
        backdrop-filter: blur(20px);
        flex-direction: column;
        padding: var(--space-8) var(--space-6);
        transition: left 0.3s ease;
        z-index: 1000;
    }
    
    .nav-menu.active {
        left: 0;
    }
    
    .nav-toggle {
        display: block;
        background: none;
        border: none;
        color: white;
        font-size: 1.5rem;
        cursor: pointer;
        z-index: 1001;
    }
}

@media (min-width: 769px) {
    .nav-toggle {
        display: none;
    }
}

/* Card grid responsive behavior */
.cards-grid {
    display: grid;
    gap: var(--space-6);
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

@media (max-width: 640px) {
    .cards-grid {
        grid-template-columns: 1fr;
        gap: var(--space-4);
    }
}

/* Form responsive behavior */
.form-grid {
    display: grid;
    gap: var(--space-4);
    grid-template-columns: 1fr;
}

@media (min-width: 640px) {
    .form-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1024px) {
    .form-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Gallery responsive behavior */
.gallery-thumbnails {
    display: flex;
    gap: var(--space-2);
    overflow-x: auto;
    padding: var(--space-4);
}

@media (max-width: 640px) {
    .gallery-thumbnails {
        padding: var(--space-3);
        gap: var(--space-1);
    }
    
    .gallery-thumbnail {
        min-width: 60px;
        height: 45px;
    }
}

/* Admin table responsive behavior */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 768px) {
    .cars-table {
        min-width: 600px;
    }
    
    .cars-table th,
    .cars-table td {
        padding: var(--space-2);
        font-size: var(--text-sm);
    }
}

/* Modal responsive behavior */
.modal-content {
    margin: var(--space-4);
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
}

@media (min-width: 640px) {
    .modal-content {
        margin: var(--space-8);
        max-width: 600px;
        margin-left: auto;
        margin-right: auto;
    }
}

@media (min-width: 1024px) {
    .modal-content {
        max-width: 800px;
    }
}

/* ===== UTILITY CLASSES FOR COMMON RESPONSIVE PATTERNS ===== */

/* Aspect ratios */
.aspect-square { aspect-ratio: 1 / 1; }
.aspect-video { aspect-ratio: 16 / 9; }
.aspect-photo { aspect-ratio: 4 / 3; }

/* Object fit */
.object-cover { object-fit: cover; }
.object-contain { object-fit: contain; }
.object-fill { object-fit: fill; }

/* Position */
.relative { position: relative; }
.absolute { position: absolute; }
.fixed { position: fixed; }
.sticky { position: sticky; }

/* Z-index */
.z-0 { z-index: 0; }
.z-10 { z-index: 10; }
.z-20 { z-index: 20; }
.z-30 { z-index: 30; }
.z-40 { z-index: 40; }
.z-50 { z-index: 50; }

/* Overflow */
.overflow-hidden { overflow: hidden; }
.overflow-auto { overflow: auto; }
.overflow-x-auto { overflow-x: auto; }
.overflow-y-auto { overflow-y: auto; }

/* Scroll behavior */
.scroll-smooth { scroll-behavior: smooth; }

/* User select */
.select-none { user-select: none; }
.select-text { user-select: text; }
.select-all { user-select: all; }

/* Pointer events */
.pointer-events-none { pointer-events: none; }
.pointer-events-auto { pointer-events: auto; }
