:root {
    /* Light Mode (Premium) */
    --primary: #0f172a;
    --primary-hover: #334155;
    --secondary: #0f172a;
    --accent: #f59e0b;
    --bg-color: #f8fafc;
    --surface: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --radius: 16px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    --shadow-lg: 0 20px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.05);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    
    --toggle-bg: #ffffff;
    --toggle-border: #e2e8f0;
    --toggle-thumb: #e2e8f0;
    --toggle-icon-active: #000000;
    --toggle-icon-inactive: #64748b;
}

[data-theme="dark"] {
    /* Dark Mode (Premium) */
    --primary: #f8fafc;
    --primary-hover: #e2e8f0;
    --secondary: #ffffff;
    --accent: #f59e0b;
    --bg-color: #09090b;
    --surface: #121214;
    --text-main: #f8fafc;
    --text-muted: #a1a1aa;
    --border: #27272a;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.5);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.5), 0 2px 4px -1px rgba(0,0,0,0.3);
    --shadow-lg: 0 20px 25px -5px rgba(0,0,0,0.5), 0 8px 10px -6px rgba(0,0,0,0.3);
    
    --toggle-bg: #09090b;
    --toggle-border: #27272a;
    --toggle-thumb: #27272a;
    --toggle-icon-active: #ffffff;
    --toggle-icon-inactive: #71717a;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* Navbar */
.navbar {
    background: var(--surface);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.nav-content {
    display: flex;
    align-items: center;
    gap: 2rem;
    height: 72px;
}

.logo {
    margin-right: auto;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--secondary);
    text-decoration: none;
    letter-spacing: -0.5px;
}

.logo span {
    color: var(--primary);
}

.nav-links {
    display: flex;
    gap: 2rem;
    align-items: center;
}

/* Global Nav Search */
.nav-search {
    position: relative;
    display: flex;
    align-items: center;
}

.nav-search input {
    background: var(--bg-color);
    border: 1px solid var(--border);
    border-radius: 9999px;
    padding: 0.5rem 1rem 0.5rem 2.5rem;
    font-size: 0.875rem;
    color: var(--text-main);
    width: 200px;
    transition: var(--transition);
    outline: none;
}

.nav-search input:focus {
    width: 250px;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.nav-search .search-icon {
    position: absolute;
    left: 0.75rem;
    color: var(--text-muted);
    pointer-events: none;
}

/* Premium Theme Toggle */
.theme-toggle {
    display: flex;
    width: 64px;
    height: 32px;
    border-radius: 9999px;
    cursor: pointer;
    background-color: var(--toggle-bg);
    border: 1px solid var(--toggle-border);
    transition: var(--transition);
    align-items: center;
    padding: 0 4px;
    box-sizing: border-box;
}

.theme-toggle-track {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
}

.theme-toggle-thumb {
    position: absolute;
    left: 0;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background-color: var(--toggle-thumb);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1;
}

[data-theme="dark"] .theme-toggle-thumb {
    transform: translateX(32px);
}

.theme-toggle-icons {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 2;
    pointer-events: none;
    padding: 0 4px;
}

.theme-toggle-icons svg {
    transition: color 0.3s ease;
}

.icon-sun {
    color: var(--toggle-icon-active);
}
.icon-moon {
    color: var(--toggle-icon-inactive);
}

[data-theme="dark"] .icon-sun {
    color: var(--toggle-icon-inactive);
}
[data-theme="dark"] .icon-moon {
    color: var(--toggle-icon-active);
}

.nav-links {
    display: flex;
    gap: 2rem;
    align-items: center;
}

.nav-link {
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 500;
    transition: var(--transition);
}

.nav-link:hover, .nav-link.active {
    color: var(--primary);
}

.mobile-menu-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    cursor: pointer;
    z-index: 2000;
}

.mobile-menu-toggle span {
    width: 25px;
    height: 2px;
    background: var(--text-main);
    transition: var(--transition);
    transform-origin: left center;
}

/* Hamburger to X Animation */
.mobile-menu-toggle.active span:nth-child(1) {
    transform: rotate(45deg);
}
.mobile-menu-toggle.active span:nth-child(2) {
    opacity: 0;
}
.mobile-menu-toggle.active span:nth-child(3) {
    transform: rotate(-45deg);
}

/* Hero Section */
.hero {
    position: relative;
    background: url('assets/hero_bg.png') center/cover no-repeat;
    color: #ffffff;
    padding: 100px 0;
    text-align: center;
    border-bottom: 1px solid var(--border);
}

.hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.65); /* Dark overlay for text readability */
    z-index: 1;
}

.hero-content {
    position: relative;
    z-index: 2;
}

.hero h1 {
    color: #ffffff;
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 1rem;
    letter-spacing: -1px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

.hero p {
    font-size: 1.25rem;
    color: #f8fafc;
    max-width: 600px;
    margin: 0 auto;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

/* Main Content Layout */
.main-content {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 2.5rem;
    padding: 3rem 1.5rem;
    min-height: 60vh;
}

.filter-header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.mobile-filter-btn {
    display: none;
}

.btn-close-modal {
    display: none;
}

.mobile-only {
    display: none;
}

@media (max-width: 900px) {
    .main-content {
        grid-template-columns: 1fr;
        padding-top: 1.5rem;
    }

    .mobile-filter-btn {
        display: inline-flex;
        align-items: center;
        gap: 0.5rem;
        background: var(--surface);
        border: 1px solid var(--border);
        padding: 0.6rem 1.25rem;
        border-radius: 9999px;
        color: var(--text-main);
        font-weight: 500;
        cursor: pointer;
        width: fit-content;
        margin-bottom: 1rem;
        box-shadow: var(--shadow-sm);
        transition: var(--transition);
    }
    
    .mobile-filter-btn:hover {
        background: var(--border);
    }
    
    .filters {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%; /* Use % to handle mobile Safari toolbars better than vh */
        z-index: 1000;
        background: var(--surface);
        display: flex;
        flex-direction: column;
        padding: 1.5rem;
        border-radius: 0;
        box-shadow: none;
        overflow-y: auto;
        transform: translateY(100%);
        opacity: 0;
        pointer-events: none;
        transition: transform 0.3s ease, opacity 0.3s ease;
    }
    
    .filters.modal-open {
        transform: translateY(0);
        opacity: 1;
        pointer-events: auto;
    }
    
    .filter-header {
        display: flex;
        margin-bottom: 2rem;
    }
    
    .btn-close-modal {
        display: flex;
        align-items: center;
        justify-content: center;
        background: var(--bg-color);
        border: 1px solid var(--border);
        border-radius: 50%;
        color: var(--text-main);
        cursor: pointer;
        width: 32px;
        height: 32px;
    }
    
    .mobile-only {
        display: block;
        margin-top: auto;
        padding-top: 2rem;
        padding-bottom: 2rem;
    }
}

/* Filters */
.filters {
    background: var(--surface);
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    height: fit-content;
}

.filter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.filter-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.btn-clear {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    text-decoration: underline;
}

.filter-group {
    margin-bottom: 1.5rem;
}

.filter-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.filter-group input, .filter-group select {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 1rem;
    transition: var(--transition);
    background-color: var(--surface); /* Use surface instead of bg-color for inputs */
    color: var(--text-main); /* Explicitly set text color */
}

.filter-group input:focus, .filter-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Active Filters (Chips Breadcrumb) */
.active-filters {
    padding: 0.75rem 1rem;
    margin-bottom: 1.5rem;
    border-radius: 0.75rem;
    background-color: var(--surface);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}

@media (min-width: 640px) {
    .active-filters {
        flex-direction: row;
        align-items: center;
        padding: 0.75rem 0.75rem;
    }
}

.active-filters-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-main);
    white-space: nowrap;
}

.filter-chips-container {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    border-radius: 9999px;
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 500;
    background-color: var(--bg-color);
    color: var(--text-main);
    border: 1px solid var(--border);
}

@media (min-width: 640px) {
    .filter-chip {
        font-size: 0.875rem;
        padding: 0.25rem 0.75rem;
    }
}

.filter-chip-text {
    max-width: 100px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (min-width: 640px) {
    .filter-chip-text {
        max-width: none;
    }
}

.filter-chip-remove {
    margin-left: 0.25rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: inherit;
    cursor: pointer;
    transition: var(--transition);
}

.filter-chip-remove:hover {
    background-color: var(--border);
    color: var(--primary);
}

.filter-chip-remove svg {
    width: 12px;
    height: 12px;
}

.btn-clear-chips {
    font-size: 0.75rem;
    text-decoration: underline;
    color: var(--text-muted);
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem;
    white-space: nowrap;
}

@media (min-width: 640px) {
    .btn-clear-chips {
        font-size: 0.875rem;
    }
}

.btn-clear-chips:hover {
    color: var(--text-main);
}

/* Listings Grid */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 2rem;
}

/* Car Card */
.car-card {
    background: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    border: 1px solid transparent;
}

.car-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--border);
}

.card-image-wrap {
    position: relative;
    width: 100%;
    padding-top: 66.66%; /* 3:2 Aspect Ratio */
    background: var(--border);
    overflow: hidden;
}

.card-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.car-card:hover .card-image {
    transform: scale(1.05);
}

.badge {
    position: absolute;
    top: 1rem;
    left: 1rem;
    background: var(--primary);
    color: var(--bg-color);
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    z-index: 10;
}

.card-content {
    padding: 1.5rem;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.card-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--secondary);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.card-year {
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 400;
}

.card-price {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 1rem;
}

.card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.meta-item svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
    flex-shrink: 0;
}

.card-desc {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    flex-grow: 1;
}

.card-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: auto;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.875rem;
    text-decoration: none;
    transition: var(--transition);
    cursor: pointer;
    flex: 1;
    gap: 0.5rem;
    border: none;
}

.btn-primary {
    background: var(--primary);
    color: var(--bg-color);
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-whatsapp {
    background: #25D366;
    color: white;
}

.btn-whatsapp:hover {
    background: #128C7E;
}

.btn-call {
    background: var(--surface);
    color: var(--text-main);
    border: 1px solid var(--border);
}

.btn-call:hover {
    background: #1e293b;
}

.btn svg {
    width: 18px;
    height: 18px;
}

/* Details for mobile horizontal cards */
@media (max-width: 600px) {
    .grid {
        grid-template-columns: 1fr;
        gap: 1.25rem;
    }

    .car-card {
        flex-direction: row;
        align-items: stretch;
        min-height: 180px; 
    }

    .card-image-wrap {
        width: 50%;
        padding-top: 0;
        flex-shrink: 0;
    }

    .card-image {
        position: absolute;
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

    .badge {
        font-size: 0.65rem;
        padding: 0.2rem 0.5rem;
        top: 0.5rem;
        left: 0.5rem;
    }

    .card-content {
        width: 50%;
        padding: 0.75rem;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }

    .card-title {
        font-size: 1rem;
        margin-bottom: 0.25rem;
    }

    .card-price {
        font-size: 1.1rem;
        margin-bottom: 0.5rem;
    }

    .card-meta {
        gap: 0.5rem;
        margin-bottom: 0.5rem;
        font-size: 0.75rem;
    }

    .meta-item svg {
        width: 14px;
        height: 14px;
    }
    
    .card-desc {
        display: none; /* Hide description on mobile horizontal to save space */
    }

    .card-actions {
        margin-top: auto;
        position: absolute;
        bottom: 0;
        left: 0;
        width: 100%;
        padding: 0.75rem;
        background: var(--surface);
        transform: translateY(100%);
        transition: transform 0.3s ease;
        opacity: 0;
        pointer-events: none;
        z-index: 10;
        border-top: 1px solid var(--border);
    }
    
    .car-card:hover .card-actions,
    .car-card:active .card-actions,
    .car-card:focus-within .card-actions {
        transform: translateY(0);
        opacity: 1;
        pointer-events: auto;
    }

    .btn {
        padding: 0.5rem;
        font-size: 0.75rem;
        margin: 0;
    }

    .btn svg {
        width: 14px;
        height: 14px;
        margin-right: -4px;
    }
}

/* States */
.hidden {
    display: none !important;
}

.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem;
    color: var(--text-muted);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(37,99,235,0.1);
    border-radius: 50%;
    border-top-color: var(--primary);
    animation: spin 1s ease-in-out infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.error-state, .empty-state {
    text-align: center;
    padding: 3rem;
    background: var(--surface);
    border-radius: var(--radius);
    color: var(--text-muted);
}

/* Premium Footer */
.footer-premium {
    background: var(--surface);
    color: var(--text-main);
    padding: 4rem 0 2rem;
    margin-top: 4rem;
    border-top: 1px solid var(--border);
}

.footer-top {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 1.5rem;
}

@media (min-width: 768px) {
    .footer-top {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }
}

.footer-logo {
    margin-bottom: 0;
}

.footer-socials {
    display: flex;
    list-style: none;
    gap: 0.75rem;
}

.btn-social {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-color);
    color: var(--text-main);
    border: 1px solid var(--border);
    transition: var(--transition);
}

.btn-social:hover {
    background: var(--border);
    color: var(--primary);
}

.footer-grid {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

@media (min-width: 1024px) {
    .footer-grid {
        grid-template-columns: repeat(10, 1fr);
        grid-template-rows: auto auto;
        gap: 1rem;
    }
    
    .footer-col-main {
        grid-column: 4 / 11;
        grid-row: 1;
        display: flex;
        justify-content: flex-end;
    }
    
    .footer-col-legal {
        grid-column: 4 / 11;
        grid-row: 2;
        display: flex;
        justify-content: flex-end;
    }
    
    .footer-col-copyright {
        grid-column: 1 / 4;
        grid-row: 1 / 3;
    }
}

.footer-links-list {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 1rem 1.5rem;
}

.footer-link, .footer-link-muted {
    text-decoration: none;
    font-size: 0.875rem;
    transition: var(--transition);
}

.footer-link {
    color: var(--primary);
}

.footer-link:hover {
    text-decoration: underline;
    text-underline-offset: 4px;
}

.footer-link-muted {
    color: var(--text-muted);
}

.footer-link-muted:hover {
    color: var(--text-main);
    text-decoration: underline;
    text-underline-offset: 4px;
}

.footer-col-copyright {
    font-size: 0.875rem;
    color: var(--text-muted);
    line-height: 1.5;
}

@media (max-width: 768px) {
    .nav-content {
        flex-wrap: wrap;
        height: auto;
        padding: 1.25rem 0;
        gap: 1.25rem;
    }
    .logo {
        flex-shrink: 0;
        margin-right: auto;
        padding-top: 0.25rem;
        margin-bottom: 0.75rem; 
    }
    .theme-toggle {
        order: 1;
        margin-left: auto;
        margin-bottom: 0.75rem;
    }
    .mobile-menu-toggle {
        display: flex;
        order: 2;
        margin-left: 0;
        margin-bottom: 0.75rem;
    }
    .nav-search {
        order: 3;
        width: 100%;
    }
    .nav-search input {
        width: 100%;
    }
    .nav-search input:focus {
        width: 100%;
    }
    .nav-links {
        position: fixed;
        top: 0;
        right: 0;
        width: 280px;
        height: 100vh;
        background: var(--surface);
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        gap: 2rem;
        box-shadow: var(--shadow-lg);
        transform: translateX(100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 1500;
        padding: 2rem;
    }
    
    .nav-links.menu-open {
        transform: translateX(0);
    }

    .nav-link {
        font-size: 1.25rem;
    }
    .hero h1 {
        font-size: 2rem;
    }
    .card-actions {
        flex-direction: column;
    }
}
