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

:root {
    --primary-color: #2c3e50;
    --secondary-color: #3498db;
    --accent-color: #e74c3c;
    --success-color: #27ae60;
    --background-color: #ecf0f1;
    --card-background: #ffffff;
    --text-color: #2c3e50;
    --text-light: #7f8c8d;
    --border-color: #bdc3c7;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 4px 20px rgba(0, 0, 0, 0.15);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

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

/* Header */
header {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    padding: 2rem 0;
    text-align: center;
    box-shadow: var(--shadow);
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.subtitle {
    font-size: 1.2rem;
    opacity: 0.9;
    margin-bottom: 0.3rem;
}

.tagline {
    font-size: 0.9rem;
    opacity: 0.8;
    font-style: italic;
}

/* Main */
main {
    flex: 1;
    padding: 2rem 0;
}

/* Search Section */
.search-section {
    background: var(--card-background);
    padding: 2rem;
    border-radius: 10px;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
}

.search-box {
    display: flex;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

#searchInput {
    flex: 1;
    padding: 1rem;
    font-size: 1rem;
    border: 2px solid var(--border-color);
    border-radius: 5px;
    outline: none;
    transition: border-color 0.3s;
}

#searchInput:focus {
    border-color: var(--secondary-color);
}

#searchBtn {
    padding: 1rem 2rem;
    font-size: 1rem;
    background: var(--secondary-color);
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.3s, transform 0.1s;
    font-weight: bold;
}

#searchBtn:hover {
    background: #2980b9;
}

#searchBtn:active {
    transform: scale(0.98);
}

.search-hint {
    color: var(--text-light);
    font-size: 0.9rem;
    text-align: center;
}

/* Loading */
.loading {
    text-align: center;
    padding: 3rem;
    background: var(--card-background);
    border-radius: 10px;
    box-shadow: var(--shadow);
}

.spinner {
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--secondary-color);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-detail {
    color: var(--text-light);
    font-size: 0.9rem;
}

/* Error */
.error {
    background: #fee;
    color: var(--accent-color);
    padding: 2rem;
    border-radius: 10px;
    border-left: 4px solid var(--accent-color);
    text-align: center;
}

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

/* Results */
.results {
    animation: fadeIn 0.5s;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.stats-container {
    margin-bottom: 2rem;
}

.stats-container h2 {
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.stats-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--card-background);
    padding: 1.5rem;
    border-radius: 10px;
    box-shadow: var(--shadow);
    text-align: center;
    border-top: 4px solid var(--secondary-color);
}

.stat-number {
    font-size: 2rem;
    font-weight: bold;
    color: var(--secondary-color);
    display: block;
    margin-bottom: 0.5rem;
}

.stat-label {
    color: var(--text-light);
    font-size: 0.9rem;
}

/* Sections */
.cheapest-section,
.all-results-section {
    background: var(--card-background);
    padding: 2rem;
    border-radius: 10px;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
}

.cheapest-section h3,
.all-results-section h3 {
    margin-bottom: 1.5rem;
    color: var(--primary-color);
}

/* Car Grid */
.car-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.car-card {
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    overflow: hidden;
    transition: transform 0.3s, box-shadow 0.3s;
    cursor: pointer;
}

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

.car-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
    background: var(--background-color);
}

.car-image.no-image {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    color: var(--text-light);
}

.car-details {
    padding: 1.5rem;
}

.car-title {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    color: var(--primary-color);
    font-weight: bold;
}

.car-price {
    font-size: 1.5rem;
    color: var(--success-color);
    font-weight: bold;
    margin-bottom: 0.5rem;
}

.car-source {
    display: inline-block;
    background: var(--secondary-color);
    color: white;
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-size: 0.8rem;
    margin-bottom: 0.5rem;
}

.car-link {
    color: var(--secondary-color);
    text-decoration: none;
    font-size: 0.9rem;
}

.car-link:hover {
    text-decoration: underline;
}

/* Car List */
.car-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.car-item {
    display: flex;
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    overflow: hidden;
    transition: transform 0.3s, box-shadow 0.3s;
    cursor: pointer;
}

.car-item:hover {
    transform: translateX(5px);
    box-shadow: var(--shadow-hover);
}

.car-item-image {
    width: 150px;
    height: 120px;
    object-fit: cover;
    background: var(--background-color);
    flex-shrink: 0;
}

.car-item-image.no-image {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: var(--text-light);
}

.car-item-details {
    padding: 1rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.car-item-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 0.5rem;
}

.car-item-title {
    font-weight: bold;
    color: var(--primary-color);
    flex: 1;
}

.car-item-price {
    font-size: 1.3rem;
    color: var(--success-color);
    font-weight: bold;
    white-space: nowrap;
    margin-left: 1rem;
}

.car-item-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Filter Controls */
.filter-controls {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.filter-controls label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.filter-controls select {
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    background: white;
    cursor: pointer;
}

/* Footer */
footer {
    background: var(--primary-color);
    color: white;
    text-align: center;
    padding: 2rem 0;
    margin-top: auto;
}

.disclaimer {
    font-size: 0.85rem;
    opacity: 0.8;
    margin-top: 0.5rem;
}

/* Responsive */
@media (max-width: 768px) {
    header h1 {
        font-size: 2rem;
    }

    .search-box {
        flex-direction: column;
    }

    .car-grid {
        grid-template-columns: 1fr;
    }

    .car-item {
        flex-direction: column;
    }

    .car-item-image {
        width: 100%;
        height: 200px;
    }

    .car-item-header {
        flex-direction: column;
    }

    .car-item-price {
        margin-left: 0;
        margin-top: 0.5rem;
    }

    .stats-cards {
        grid-template-columns: 1fr;
    }
}

/* Filter Section */
.filter-section {
    background: var(--card-background);
    padding: 2rem;
    border-radius: 10px;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
}

.filter-section h2 {
    margin-bottom: 1.5rem;
    color: var(--primary-color);
}

.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.filter-group label {
    font-weight: 600;
    color: var(--primary-color);
    font-size: 0.9rem;
}

.filter-group select {
    padding: 0.8rem;
    border: 2px solid var(--border-color);
    border-radius: 5px;
    font-size: 1rem;
    background: white;
    cursor: pointer;
    transition: border-color 0.3s;
}

.filter-group select:focus {
    outline: none;
    border-color: var(--secondary-color);
}

.filter-group select:disabled {
    background: #f5f5f5;
    cursor: not-allowed;
}

.btn-search,
.btn-clear {
    padding: 0.8rem 1.5rem;
    border: none;
    border-radius: 5px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-search {
    background: var(--secondary-color);
    color: white;
    margin-bottom: 0.5rem;
}

.btn-search:hover {
    background: #2980b9;
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.btn-clear {
    background: #95a5a6;
    color: white;
}

.btn-clear:hover {
    background: #7f8c8d;
}

/* Results Header */
.results-header {
    text-align: center;
    margin-bottom: 2rem;
}

.results-header h2 {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.results-subtitle {
    color: var(--text-light);
    font-size: 0.9rem;
}

/* Cars List */
.cars-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 2rem;
}

.car-card {
    background: var(--card-background);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: transform 0.3s, box-shadow 0.3s;
}

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

.car-image-container {
    position: relative;
    height: 200px;
    overflow: hidden;
    background: var(--background-color);
}

.car-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.car-image-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 4rem;
    color: var(--text-light);
}

.car-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: var(--secondary-color);
    color: white;
    padding: 0.4rem 0.8rem;
    border-radius: 5px;
    font-size: 0.85rem;
    font-weight: 600;
}

.car-details {
    padding: 1.5rem;
}

.car-header {
    margin-bottom: 1rem;
}

.car-name {
    font-size: 1.3rem;
    color: var(--primary-color);
    margin-bottom: 0.3rem;
}

.car-version {
    color: var(--text-light);
    font-size: 0.9rem;
}

.car-pricing {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 5px;
    margin-bottom: 1rem;
}

.best-price {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 0.5rem;
}

.price-label {
    font-size: 0.85rem;
    color: var(--text-light);
    font-weight: 600;
}

.price-value {
    font-size: 1.8rem;
    color: var(--success-color);
    font-weight: bold;
}

.price-source {
    display: flex;
    gap: 0.5rem;
    font-size: 0.85rem;
}

.source-label {
    color: var(--text-light);
}

.source-name {
    color: var(--secondary-color);
    font-weight: 600;
}

.price-comparison {
    text-align: center;
    padding: 0.5rem;
    background: #e8f5e9;
    border-radius: 5px;
    margin-bottom: 1rem;
}

.price-count {
    font-size: 0.85rem;
    color: var(--success-color);
    font-weight: 600;
}

.price-rank {
    font-size: 0.75rem;
    color: var(--success-color);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Alternative Prices Section */
.alternative-prices {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.toggle-alternatives {
    width: 100%;
    padding: 0.7rem 1rem;
    background: #f8f9fa;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s;
    font-size: 0.9rem;
    color: var(--text-color);
}

.toggle-alternatives:hover {
    background: #e9ecef;
    border-color: var(--secondary-color);
}

.alt-count {
    font-weight: 600;
    color: var(--secondary-color);
}

.toggle-icon {
    font-size: 0.8rem;
    color: var(--text-light);
    transition: transform 0.3s;
}

.alternatives-list {
    margin-top: 0.8rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    max-height: 400px;
    overflow-y: auto;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        max-height: 0;
    }
    to {
        opacity: 1;
        max-height: 400px;
    }
}

.alternatives-list.hidden {
    display: none;
}

.alternative-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.8rem;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 5px;
    transition: all 0.2s;
}

.alternative-item:hover {
    background: white;
    border-color: var(--secondary-color);
    transform: translateX(3px);
}

.alt-rank {
    font-size: 1.1rem;
    font-weight: bold;
    color: var(--text-light);
    min-width: 35px;
    text-align: center;
    background: white;
    padding: 0.3rem 0.5rem;
    border-radius: 5px;
}

.alt-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.alt-price {
    font-size: 1.1rem;
    font-weight: bold;
    color: var(--success-color);
}

.alt-source {
    font-size: 0.8rem;
    color: var(--text-light);
}

.alt-link {
    padding: 0.5rem 1rem;
    background: var(--secondary-color);
    color: white;
    text-decoration: none;
    border-radius: 5px;
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    transition: all 0.2s;
}

.alt-link:hover {
    background: #2980b9;
    transform: scale(1.05);
}

.car-actions {
    margin-top: 1rem;
}

.btn-view {
    display: block;
    width: 100%;
    padding: 0.8rem;
    background: var(--secondary-color);
    color: white;
    text-align: center;
    text-decoration: none;
    border-radius: 5px;
    font-weight: 600;
    transition: all 0.3s;
}

.btn-view:hover {
    background: #2980b9;
    transform: translateY(-2px);
}

.no-results {
    text-align: center;
    padding: 3rem;
    color: var(--text-light);
    font-size: 1.1rem;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .filter-grid {
        grid-template-columns: 1fr;
    }

    .cars-list {
        grid-template-columns: 1fr;
    }

    .car-name {
        font-size: 1.1rem;
    }

    .price-value {
        font-size: 1.5rem;
    }

    /* Alternative prices mobile optimization */
    .alternative-item {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }

    .alt-rank {
        align-self: flex-start;
    }

    .alt-link {
        width: 100%;
        text-align: center;
    }

    .toggle-alternatives {
        font-size: 0.85rem;
        padding: 0.6rem 0.8rem;
    }
}
