:root {
    /* Light Theme Variables (Default) */
    --bg-color: #e0e5ec;
    --text-color: #4a4a4a;
    --primary-color: #6a11cb;
    --accent-color: #2575fc;

    /* Neumorphism Shadows - Light */
    --shadow-light: 9px 9px 16px rgb(163, 177, 198, 0.6), -9px -9px 16px rgba(255, 255, 255, 0.5);
    --shadow-inner: inset 6px 6px 10px 0 rgba(163, 177, 198, 0.7), inset -6px -6px 10px 0 rgba(255, 255, 255, 0.8);

    --card-bg: #e0e5ec;
    --btn-bg: #e0e5ec;

    --font-family: 'Montserrat', sans-serif;
    --radius: 16px;
    --transition: 0.3s ease;
}

[data-theme="dark"] {
    /* Dark Theme Variables */
    --bg-color: #292d3e;
    --text-color: #e0e5ec;
    --primary-color: #a78bfa;
    /* Lighter purple for dark mode */
    --accent-color: #60a5fa;

    /* Neumorphism Shadows - Dark */
    --shadow-light: 6px 6px 12px #1f222e, -6px -6px 12px #33384e;
    --shadow-inner: inset 4px 4px 8px #1f222e, inset -4px -4px 8px #33384e;

    --card-bg: #292d3e;
    --btn-bg: #292d3e;
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-family);
    transition: background-color var(--transition), color var(--transition);
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
.header {
    padding: 12px 0;
    margin-bottom: 40px;
    background-color: var(--bg-color);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    /* Subtle shadow for header separation */
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 50px;
    /* Ensure consistent height */
}

.header-left {
    display: flex;
    align-items: center;
    gap: 30px;
}

.logo-link {
    text-decoration: none;
    color: inherit;
    transition: var(--transition);
}

.logo-link:hover {
    opacity: 0.8;
}

.logo-image {
    height: 50px;
    width: auto;
    display: block;
    transition: var(--transition);
}

/* Optional: Adjust logo for dark theme if needed */
[data-theme="dark"] .logo-image {
    filter: brightness(1.1);
}

.city-info {
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
}

.theme-toggle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--btn-bg);
    box-shadow: var(--shadow-light);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    color: var(--text-color);
    transition: var(--transition);
}

.theme-toggle:active {
    box-shadow: var(--shadow-inner);
}

/* Info Block */
.info-block {
    text-align: center;
    margin-bottom: 40px;
}

.info-block h1 {
    font-size: 1.8rem;
    margin-bottom: 20px;
    color: var(--text-color);
}

.info-block p {
    font-size: 0.95rem;
    max-width: 800px;
    margin: 0 auto;
    opacity: 0.8;
}

/* Filters */
.filters {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 30px;
}

@media (max-width: 600px) {
    .filters {
        display: grid;
        grid-template-columns: 1fr 1fr;
        max-width: 500px;
        margin-left: auto;
        margin-right: auto;
    }
}

.filter-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 12px;
    background: var(--btn-bg);
    color: var(--text-color);
    font-family: var(--font-family);
    font-weight: 600;
    box-shadow: var(--shadow-light);
    cursor: pointer;
    transition: var(--transition);
}

.filter-btn:hover {
    transform: translateY(-2px);
}

.filter-btn.active,
.filter-btn:active {
    box-shadow: var(--shadow-inner);
    color: var(--primary-color);
}

/* Car Catalog (Grid) */
.car-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 30px;
    margin-bottom: 50px;
}

.car-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow-light);
    overflow: hidden;
    transition: var(--transition);
    cursor: pointer;
    position: relative;
}

.car-card:hover {
    transform: translateY(-5px);
}

.car-image-wrapper {
    height: 250px;
    overflow: hidden;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.car-image-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
    background: #1a1b24;
    /* Fallback background */
}

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

.car-info {
    padding: 15px;
}

.car-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
}

.car-title {
    font-size: 1.1rem;
    font-weight: 700;
    line-height: 1.2;
}

.car-price {
    font-weight: 700;
    color: var(--primary-color);
    font-size: 1.1rem;
    margin-bottom: 5px;
}

.car-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    opacity: 0.7;
    margin-top: 5px;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 60px;
}

.page-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: var(--btn-bg);
    color: var(--text-color);
    box-shadow: var(--shadow-light);
    cursor: pointer;
    font-weight: 600;
    transition: var(--transition);
}

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

.page-btn.active {
    box-shadow: var(--shadow-inner);
    color: var(--primary-color);
}

/* Footer */
.footer {
    padding: 30px 0;
    text-align: center;
    font-size: 0.9rem;
    opacity: 0.6;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    /* Standard dim overlay */
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--bg-color);
    width: 95%;
    max-width: 1000px;
    border-radius: var(--radius);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    padding: 40px 30px 30px 30px;
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
}

.close-modal {
    position: absolute;
    top: -5px;
    right: 5px;
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: var(--text-color);
    z-index: 10;
}

.modal-body {
    display: grid;
    grid-template-columns: 1fr 1.1fr;
    gap: 30px;
}

@media (max-width: 768px) {

    /* Layout */
    .header-content {
        flex-direction: column;
        justify-content: center;
        align-items: center;
        position: relative;
        /* For absolute positioning of toggle */
        padding-top: 10px;
        /* Slight adjustment if needed */
    }

    .header-left {
        flex-direction: column;
        gap: 15px;
        text-align: center;
        width: 100%;
    }

    .theme-toggle {
        position: absolute;
        top: 4px;
        /* Align with header padding */
        right: 20px;
        /* Space from edge */
    }

    .logo-image {
        height: 40px;
        /* Slightly smaller on mobile */
    }

    /* Filters - Grid Layout (Equal Sizes) */
    .filters {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 15px;
        margin-bottom: 30px;
        padding: 0;
    }

    .filter-btn {
        width: 100%;
        min-width: 0;
        /* Prevent overflow */
        font-size: 0.85rem;
        padding: 0 5px;
        display: flex;
        justify-content: center;
        align-items: center;
        height: 50px;
        /* Fixed height */
    }

    .sort-dropdown {
        width: 100%;
    }

    .sort-btn {
        width: 100%;
        justify-content: center;
        height: 50px;
        /* Match filter-btn */
        font-size: 0.85rem;
        box-sizing: border-box;
    }

    .sort-options {
        width: 100%;
        left: 0;
    }

    /* Grid */
    .car-grid {
        grid-template-columns: 1fr;
        /* Single column */
        gap: 20px;
    }

    /* Modal */
    .modal-body {
        grid-template-columns: 1fr;
    }

    .modal-content {
        width: calc(100% - 20px);
        margin: 10px auto;
        padding: 40px 10px 20px 10px;
    }

    .main-image-container {
        height: 220px;
    }

    .main-image-container img {
        object-fit: cover;
    }

    .car-image-wrapper {
        height: 200px;
    }

    .car-image-wrapper img {
        object-fit: cover;
    }

    .modal-info h2 {
        font-size: 1.5rem;
    }

    .modal-price {
        font-size: 1.3rem;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 15px;
    }

    .car-image-wrapper {
        height: 200px;
    }

    .info-block h1 {
        font-size: 1.4rem;
    }

    .modal-content {
        padding: 35px 8px 20px 8px;
    }

    .weekly-price-table {
        table-layout: fixed;
        width: 100% !important;
        min-width: 0 !important;
        font-size: 0.55rem;
    }

    .weekly-price-table td:first-child,
    .weekly-price-table th:first-child {
        width: 60px;
        padding-left: 2px;
        white-space: normal;
        line-height: 1.1;
    }

    .weekly-price-table th,
    .weekly-price-table td {
        padding: 4px 0px;
    }

    .weekly-price-table td:not(:first-child) {
        white-space: nowrap;
    }
}


.modal-gallery {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.main-image-container {
    height: 300px;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow-inner);
}

.main-image-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.thumbnail-row {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 5px;
}

.thumbnail {
    width: 70px;
    height: 50px;
    border-radius: 6px;
    object-fit: cover;
    cursor: pointer;
    transition: var(--transition);
}

.thumbnail:active,
.thumbnail.active {
    filter: brightness(0.9);
}


.modal-info h2 {
    margin-bottom: 10px;
}

.modal-brand {
    font-size: 1.7rem;
    font-weight: 700;
    line-height: 1.1;
}

.modal-model {
    font-size: 1.5rem;
    font-weight: 600;
    opacity: 0.9;
    line-height: 1.1;
}

.modal-price {
    font-size: 1.4rem;
    color: var(--primary-color);
    font-weight: 700;
    margin-bottom: 15px;
}

.modal-specs {
    margin-bottom: 5px;
}

.spec-item {
    display: flex;
    justify-content: space-between;
    padding: 3px 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    font-size: 0.85rem;
}

.spec-label {
    font-weight: 500;
    opacity: 0.7;
}

.spec-value {
    font-weight: 600;
}

.modal-description {
    line-height: 1.5;
    margin-bottom: 8px;
    opacity: 0.9;
    font-size: 0.95rem;
    background: rgba(0, 0, 0, 0.03);
    border-radius: 12px;
    padding: 15px;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .modal-description {
    background: rgb(35, 37, 50);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

/* Weekly Price Table */
.weekly-prices-container {
    margin-top: 0;
    margin-bottom: 10px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    background: rgba(0, 0, 0, 0.03);
    border-radius: 12px;
    padding: 10px;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .weekly-prices-container {
    background: rgb(35, 37, 50);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.weekly-price-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.65rem;
    min-width: 320px;
}

.weekly-price-table th,
.weekly-price-table td {
    padding: 6px 2px;
    text-align: center;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    white-space: nowrap;
}

body.dark-theme .weekly-price-table th,
body.dark-theme .weekly-price-table td {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.weekly-price-table th {
    padding: 12px 12px;
    font-weight: 600;
    opacity: 0.8;
    background: rgba(0, 0, 0, 0.02);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

body.dark-theme .weekly-price-table th {
    background: rgba(255, 255, 255, 0.03);
}

.weekly-price-table td:first-child,
.weekly-price-table th:first-child {
    text-align: left;
    padding-left: 5px;
    font-weight: 600;
    width: 100px;
    color: var(--primary-color);
}

body.dark-theme .weekly-price-table td:first-child,
body.dark-theme .weekly-price-table th:first-child {
    color: var(--accent-color);
}

.weekly-price-table tr:last-child td {
    border-bottom: none;
}

.contact-btn {
    width: 100%;
    padding: 10px;
    border: none;
    border-radius: 12px;
    background: var(--bg-color);
    /* Initial state similar to bg */
    color: white;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 6px 6px 10px rgba(0, 0, 0, 0.2), -6px -6px 10px rgba(255, 255, 255, 0.1);
    background: linear-gradient(145deg, var(--primary-color), var(--accent-color));
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    margin-top: 10px;
    margin-bottom: 15px;
}

.contact-btn:hover {
    transform: translateY(-2px);
    box-shadow: 8px 8px 15px rgba(0, 0, 0, 0.25), -8px -8px 15px rgba(255, 255, 255, 0.1);
}

.contact-btn:active {
    transform: translateY(0);
}

/* Contacts Popup (Nested in Modal) */
.contacts-popup {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    background: var(--bg-color);
    padding: 30px;
    border-radius: var(--radius);
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.3);
    text-align: center;
    width: 80%;
    max-width: 400px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    /* Bounce effect */
    z-index: 20;
}

.contacts-popup.active {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

.close-popup {
    position: absolute;
    top: 10px;
    right: 15px;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-color);
}

.contacts-popup h3 {
    margin-bottom: 20px;
}

.phone-link {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-color);
    text-decoration: none;
    margin-bottom: 20px;
}

.contact-actions {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 15px;
}

.telegram-btn,
.whatsapp-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5rem;
    color: white;
    text-decoration: none;
    transition: transform 0.3s ease;
}

.telegram-btn {
    background: #0088cc;
}

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

.telegram-btn:hover,
.whatsapp-btn:hover {
    transform: scale(1.1);
}

.popup-note {
    font-size: 0.8rem;
    opacity: 0.6;
    margin-top: 15px;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.car-card {
    animation: fadeIn 0.5s ease forwards;
}

/* --- Adaptive Mobile Specific Overrides --- */
body.is-mobile .modal-content {
    width: 96%;
    padding: 25px 10px 15px 10px;
}

body.is-mobile .modal-brand {
    font-size: 1.4rem;
}

body.is-mobile .modal-model {
    font-size: 1.2rem;
}

body.is-mobile .modal-price {
    font-size: 1.25rem;
    margin-bottom: 10px;
}

body.is-mobile .modal-description {
    font-size: 0.85rem;
    padding: 10px;
}

body.is-mobile .spec-item {
    font-size: 0.75rem;
    padding: 2px 0;
}

body.is-mobile .main-image-container {
    height: 180px;
    width: 80%;
    margin: 0 auto;
}

body.is-mobile .weekly-price-table {
    font-size: 0.6rem;
    min-width: 0;
}

body.is-mobile .weekly-prices-container {
    padding: 8px;
}

body.is-mobile .contact-btn {
    font-size: 1rem;
    padding: 8px;
}

body.is-mobile .close-modal {
    top: 5px;
    right: 12px;
    font-size: 1.8rem;
}

body.is-mobile .thumbnail {
    width: 45px;
    height: 32px;
}

body.is-mobile .thumbnail-row {
    justify-content: center;
    gap: 8px;
}