/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Reset webkit select styling globally */
select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
}

.container {
    width: 80%;
    margin: 0 auto;
    padding: 20px;
}


/* Compact navigation header (permanent) */
.compact-nav {
    background-color: #2152e6;
    color: white;
    padding: 12px 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.compact-nav .container {
    padding: 0 20px;
}

.compact-nav .nav-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.compact-nav .nav-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.profile-link {
    background: #ffffff;
    color: #667eea;
    border: 2px solid #667eea;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    font-size: 16px;
    transition: all 0.2s;
    flex-shrink: 0;
    font-weight: bold;
}

.profile-link:hover {
    background: #667eea;
    color: white;
    transform: translateY(-1px);
    text-decoration: none;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.compact-nav .logo {
    font-size: 1.4rem;
    font-weight: 700;
}

.compact-nav .logo a {
    color: white;
    text-decoration: none;
}

.compact-nav .tagline {
    font-size: 0.9rem;
    opacity: 0.9;
}

.compact-nav .new-search-btn {
    background-color: #0056b3;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background-color 0.2s;
}

.compact-nav .new-search-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.compact-nav .nav-right {
    display: flex;
    align-items: center;
}

.compact-nav .user-info {
    display: flex;
    align-items: center;
    gap: 15px;
    font-size: 0.9rem;
}

.compact-nav .user-greeting {
    color: rgba(255, 255, 255, 0.9);
    font-weight: 500;
}

.compact-nav .admin-link {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    text-decoration: none;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 500;
    transition: background-color 0.2s;
}

.compact-nav .admin-link:hover {
    background: rgba(255, 255, 255, 0.25);
}

.compact-nav .logout-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    text-decoration: none;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 500;
    transition: background-color 0.2s;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.compact-nav .logout-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Alert Messages */
.alert {
    padding: 12px 20px;
    margin: 20px 0;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 500;
    border: 1px solid transparent;
}

.alert-error {
    background-color: #fef2f2;
    color: #dc2626;
    border-color: #fecaca;
}

.alert-success {
    background-color: #f0fdf4;
    color: #16a34a;
    border-color: #bbf7d0;
}

.alert-warning {
    background-color: #fffbeb;
    color: #d97706;
    border-color: #fed7aa;
}

.alert-info {
    background-color: #eff6ff;
    color: #2563eb;
    border-color: #dbeafe;
}

/* Form styles */
.search-form {
    background: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin-bottom: 40px;
}

.form-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-row {
    display: grid;
    grid-template-columns: minmax(160px, 0.8fr) minmax(160px, 0.8fr) 240px;
    gap: 20px;
    align-items: stretch;
}

.form-row button {
    width: 100%;
    align-self: flex-end;
}

.stacked-fields {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.half-width-row {
    display: flex;
    gap: 10px;
}

.half-width-row .form-group {
    flex: 1;
}

.button-column {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    height: 100%;
}

.button-column button:first-child {
    margin-top: 28px; /* Align with first row fields */
    margin-bottom: 15px; /* Gap between buttons */
}

.button-column button:last-child {
    margin-top: 25px; /* Align with second row fields */
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    font-weight: 600;
    margin-bottom: 8px;
    color: #555;
}

.form-group select,
.form-group input[type="text"],
.form-group input[type="number"] {
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
    background: white;
    transition: border-color 0.2s;
    width: 100%;
}

/* Override webkit default select styling */
.form-group select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 20px;
    padding-right: 40px;
}

.form-group select:focus,
.form-group input[type="text"]:focus,
.form-group input[type="number"]:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-group select:disabled {
    background: #f9f9f9;
    cursor: not-allowed;
}

/* Location controls */
.location-group {
    /* Removed border and padding for better integration */
}

.location-controls {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 12px;
    align-items: center;
}

.location-btn {
    background: #28a745;
    color: white;
    border: none;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.location-btn:hover {
    background: #218838;
    transform: translateY(-1px);
}

.location-btn:disabled {
    background: #6c757d;
    cursor: not-allowed;
    transform: none;
}

.location-btn.getting-location {
    background: #ffc107;
    color: #212529;
}

.location-status {
    font-size: 14px;
    margin-top: 8px;
    padding: 8px 12px;
    border-radius: 6px;
    display: none;
}

.location-status.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
    display: block;
}

.location-status.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    display: block;
}

/* Hide mobile buttons on desktop */
.mobile-buttons {
    display: none;
}

/* Hide mobile form fields on desktop by default */
.mobile-form-fields {
    display: none;
}


@media (max-width: 768px) {
    /* Form layout adjustments for mobile */
    .form-container {
        display: block;
    }
    
    /* Show mobile form, hide desktop form on mobile */
    .mobile-form-fields {
        display: block;
    }
    
    .desktop-form {
        display: none;
    }
    
    
    /* Style mobile form fields */
    .mobile-form-fields .form-group {
        margin-bottom: 20px;
    }
    
    .form-group {
        margin-bottom: 15px;
    }
    
    /* Hide desktop buttons on mobile */
    .desktop-only {
        display: none !important;
    }
    
    /* Show mobile buttons container */
    .mobile-buttons {
        display: flex;
        flex-direction: column;
        gap: 10px;
        margin-top: 20px;
    }
    
    .mobile-buttons button {
        width: 100%;
    }
    
    .location-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .location-btn {
        justify-content: center;
    }
    
    /* Fix location filter layout on mobile */
    .location-filter-controls {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .location-filter .location-btn,
    .location-filter select,
    .location-filter .clear-location-btn {
        width: 100%;
    }
}


.search-btn {
    background-color: #0056b3;
    color: white;
    border: none;
    padding: 14px 20px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.search-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

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

.search-btn.loading .normal {
    display: none;
}

.search-btn:not(.loading) .htmx-indicator {
    display: none;
}

.clear-btn {
    background: #6c757d;
    color: white;
    border: none;
    padding: 14px 20px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.clear-btn:hover {
    background: #5a6268;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(108, 117, 125, 0.3);
}

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


/* Results styles */
.results-container {
    margin-top: 40px;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
    gap: 20px;
}

.results-info {
    flex: 1;
}

.layout-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.layout-label {
    font-size: 0.9rem;
    color: #666;
    font-weight: 500;
}

.layout-buttons {
    display: flex;
    background: white;
    border-radius: 6px;
    padding: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border: 1px solid #e5e5e5;
}

.layout-btn {
    background: none;
    border: none;
    padding: 8px 10px;
    border-radius: 4px;
    cursor: pointer;
    color: #666;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.layout-btn:hover {
    background: #f8f9ff;
    color: #333;
}

.layout-btn.active {
    background: #667eea;
    color: white;
    box-shadow: 0 2px 4px rgba(102, 126, 234, 0.3);
}

.layout-btn svg {
    width: 16px;
    height: 16px;
}

/* Location filter (appears above results after search) */
.location-filter {
    display: none;
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
    border: 1px solid #e5e5e5;
}

.location-filter h3 {
    margin: 0 0 15px 0;
    font-size: 1.1rem;
    color: #333;
    display: flex;
    align-items: center;
    gap: 8px;
}

.location-filter-controls {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 15px;
    align-items: center;
}

.location-filter .location-btn {
    background: #28a745;
    color: white;
    border: none;
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.location-filter .location-btn:hover {
    background: #218838;
}

.location-filter .location-btn:disabled {
    background: #6c757d;
    cursor: not-allowed;
}

.location-filter .location-btn.getting-location {
    background: #ffc107;
    color: #212529;
}

.location-filter select {
    padding: 10px 12px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    background: white;
    min-width: 150px;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 18px;
    padding-right: 35px;
}

.location-filter select:disabled {
    background: #f9f9f9;
    cursor: not-allowed;
}

.location-filter .clear-location-btn {
    background: #dc3545;
    color: white;
    border: none;
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    display: none;
}

.location-filter .clear-location-btn:hover {
    background: #c82333;
}

.results-count {
    font-size: 1.1rem;
    color: #666;
    margin-bottom: 20px;
    text-align: center;
}

.dealers-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
    gap: 20px;
}

/* 2-column layout */
.dealers-grid[data-layout="grid-2"] {
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

/* List layout */
.dealers-grid[data-layout="list"] {
    grid-template-columns: 1fr;
    gap: 15px;
}

.dealers-grid[data-layout="list"] .dealer-card {
    display: flex;
    flex-direction: column;
    min-height: auto;
}

.dealers-grid[data-layout="list"] .dealer-main-row {
    display: flex;
    flex-direction: row;
    align-items: stretch;
}

.dealers-grid[data-layout="list"] .dealer-header {
    flex: 0 0 300px;
    border-right: 1px solid #eee;
    margin-right: 20px;
    padding-right: 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.dealers-grid[data-layout="list"] .dealer-info {
    flex: 1;
    padding: 15px 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 15px;
}

.dealers-grid[data-layout="list"] .dealer-info p {
    margin: 0;
    white-space: nowrap;
}

.dealers-grid[data-layout="list"] .dealer-stats {
    flex: 0 0 200px;
    margin-left: 20px;
    border-left: 1px solid #eee;
    padding-left: 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 10px;
}

.dealers-grid[data-layout="list"] .similar-cars {
    width: 100%;
    margin-top: 0;
    border-top: 1px solid #eee;
    background: #f8f9ff;
}

.inline-toggle-btn {
    display: none; /* Hidden by default */
}

.dealers-grid[data-layout="list"] .inline-toggle-btn {
    display: inline; /* Show only in list layout */
    background: none;
    border: none;
    color: #667eea;
    font-size: 0.8rem;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 3px;
    margin-left: 8px;
    transition: all 0.2s ease;
}

.dealers-grid[data-layout="list"] .inline-toggle-btn:hover {
    background: #f0f2ff;
    color: #5a67d8;
}

.dealers-grid[data-layout="list"] .inline-toggle-btn.active {
    color: #dc3545;
}

.dealers-grid[data-layout="list"] .toggle-btn {
    display: none; /* Hide regular toggle button in list view */
}

.dealers-grid[data-layout="list"] .similar-cars-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 10px;
    padding: 15px;
}

.dealers-grid[data-layout="list"] .similar-car {
    background: white;
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid #e5e5e5;
    font-size: 0.85rem;
}

.dealers-grid[data-layout="list"] .similar-car .car-link {
    padding: 0;
}

.dealers-grid[data-layout="list"] .car-details {
    font-size: 0.85rem;
    line-height: 1.3;
}

.dealers-grid[data-layout="list"] .sale-date {
    font-size: 0.75rem;
    color: #888;
}

.dealer-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
}

.dealer-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.dealer-header {
    padding: 20px 20px 15px;
    background: white;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.dealer-header h3 {
    font-size: 1.3rem;
    color: #333;
    margin: 0;
    flex: 1;
}

.dealer-name-link {
    color: #0056b3;
    text-decoration: none;
    transition: color 0.2s;
}

.dealer-name-link:hover {
    color: #357abd;
    text-decoration: underline;
}

.score {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    min-width: 100px;
}

.score-label {
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 4px;
}

.score-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #667eea;
    background: white;
    padding: 0;
    border-radius: 20px;
    border: 2px solid #667eea;
}

.dealer-info {
    padding: 15px 20px;
}

.dealer-info p {
    margin: 8px 0;
    color: #555;
    display: flex;
    align-items: center;
}

.dealer-info .distance {
    color: #28a745;
    font-weight: 600;
}

.dealer-stats {
    padding: 15px 20px;
    background: #f9f9f9;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.stat {
    text-align: center;
}

.stat-label {
    display: block;
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 4px;
}

.stat-value {
    display: block;
    font-size: 1.2rem;
    font-weight: 700;
    color: #333;
}

.similar-cars {
    border-top: 1px solid #eee;
}

.toggle-btn {
    width: 100%;
    padding: 15px 20px;
    background: #ccc;
    border: none;
    cursor: pointer;
    text-align: left;
    font-weight: 600;
    color: black;
    transition: background-color 0.2s;
}

.toggle-btn:hover {
    background: #f8f9ff;
}

.toggle-btn.active {
    background: #ccc;
    color: black;
}

.similar-cars-list {
    padding: 0 20px 20px;
    max-height: 300px;
    overflow-y: auto;
}

.similar-car {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #f0f0f0;
}

.similar-car:last-child {
    border-bottom: none;
}

/* Make similar cars clickable */
.similar-car .car-link {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    text-decoration: none;
    color: inherit;
    padding: 4px;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.similar-car .car-link:hover {
    background-color: #f8f9fa;
    text-decoration: none;
    color: inherit;
}

.similar-car .car-link:hover .car-details {
    color: #007bff;
}

.car-details {
    font-weight: 500;
    flex: 1;
}

.sale-date {
    font-size: 0.9rem;
    color: #666;
    min-width: 100px;
    text-align: right;
}

.no-results {
    text-align: center;
    padding: 60px 20px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.no-results h2 {
    color: #666;
    margin-bottom: 15px;
}

.no-results p {
    color: #888;
    margin-bottom: 10px;
}

/* Responsive design */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }

    /* Results header responsive */
    .results-header {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }

    /* Hide layout controls on mobile */
    .layout-controls {
        display: none;
    }

    /* Force single column on mobile regardless of layout choice */
    .dealers-grid,
    .dealers-grid[data-layout="grid-2"],
    .dealers-grid[data-layout="grid-3"] {
        grid-template-columns: 1fr !important;
    }

    /* Make list layout stack vertically on mobile */
    .dealers-grid[data-layout="list"] .dealer-main-row {
        flex-direction: column;
    }

    .dealers-grid[data-layout="list"] .dealer-header {
        flex: none;
        border-right: none;
        border-bottom: 1px solid #eee;
        margin-right: 0;
        margin-bottom: 15px;
        padding-right: 0;
        padding-bottom: 15px;
    }

    .dealers-grid[data-layout="list"] .dealer-info {
        padding: 15px;
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .dealers-grid[data-layout="list"] .dealer-stats {
        flex: none;
        margin-left: 0;
        border-left: none;
        border-top: 1px solid #eee;
        padding-left: 0;
        padding-top: 15px;
        margin-top: 15px;
    }

    .dealers-grid[data-layout="list"] .similar-cars {
        display: block; /* Show similar cars on mobile even in list view */
    }
    
    /* Fix compact navigation on mobile */
    .compact-nav .nav-content {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .compact-nav .nav-left {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
        width: 100%;
    }
    
    .compact-nav .logo {
        font-size: 1.2rem;
    }
    
    .compact-nav .tagline {
        font-size: 0.85rem;
        line-height: 1.3;
    }
    
    .compact-nav .nav-right {
        width: 100%;
    }
    
    .compact-nav .user-info {
        flex-wrap: wrap;
        gap: 10px;
        font-size: 0.85rem;
    }
    
    header {
        padding: 30px 20px;
    }
    
    header h1 {
        font-size: 2rem;
    }

    .search-btn {
        padding-top: 14px;
        padding-bottom: 14px;
        background-color: #0056b3;
    }
    
    .search-form {
        grid-template-columns: 1fr;
        padding: 20px;
        margin-left:-48px;
        margin-right:-48px;
    }
    
    .dealers-grid {
        grid-template-columns: 1fr;
    }
    
    .dealer-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    
    .score {
        align-items: flex-start;
        min-width: auto;
    }
    
    .dealer-stats {
        grid-template-columns: 1fr;
    }
}

/* Dealer Detail Styles */
.dealer-info-section {
    margin-bottom: 30px;
}

.dealer-info-card {
    background: white;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.dealer-info-card h2 {
    margin-bottom: 20px;
    color: #333;
    border-bottom: 2px solid #667eea;
    padding-bottom: 10px;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
    margin-bottom: 30px;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.info-item label {
    font-weight: 600;
    color: #555;
    font-size: 0.9rem;
}

.info-item span {
    font-size: 1rem;
    color: #333;
}

/* Map Styles */
.map-section {
    margin-top: 30px;
}

.map-section h3 {
    margin-bottom: 15px;
    color: #333;
}

.dealer-map {
    height: 300px;
    border-radius: 8px;
    border: 2px solid #ddd;
    position: relative;
    z-index: 1;
}

/* Ensure Leaflet map components stay below navigation */
.dealer-map .leaflet-pane,
.dealer-map .leaflet-tile-pane,
.dealer-map .leaflet-overlay-pane,
.dealer-map .leaflet-shadow-pane,
.dealer-map .leaflet-marker-pane,
.dealer-map .leaflet-tooltip-pane,
.dealer-map .leaflet-popup-pane,
.dealer-map .leaflet-map-pane,
.dealer-map .leaflet-objects-pane,
.dealer-map .leaflet-control-container {
    z-index: auto !important;
}

/* Override any high z-index values from Leaflet */
#map * {
    z-index: auto !important;
}

/* Tabs Styles */
.tabs-container {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.tabs {
    display: flex;
    background: #f8f9ff;
    border-bottom: 1px solid #eee;
}

.tab-button {
    flex: 1;
    padding: 15px 20px;
    background: none;
    border: none;
    cursor: pointer;
    font-weight: 600;
    color: #666;
    transition: all 0.2s;
    border-bottom: 3px solid transparent;
}

.tab-button.active {
    color: #667eea;
    background: white;
    border-bottom-color: #667eea;
}

.tab-button:hover:not(.active) {
    background: #f0f2ff;
    color: #555;
}

.tab-content {
    padding: 30px;
}

/* Table Styles */
.cars-table-container {
    width: 100%;
}

.table-controls {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    align-items: center;
}

.filter-input, .sort-select {
    padding: 10px 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
}

.filter-input {
    flex: 1;
    max-width: 300px;
}

.filter-input:focus, .sort-select:focus {
    outline: none;
    border-color: #667eea;
}

.cars-table-wrapper {
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid #ddd;
}

.cars-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.cars-table th {
    background: #f8f9ff;
    padding: 12px;
    text-align: left;
    font-weight: 600;
    color: #555;
    border-bottom: 2px solid #eee;
    white-space: nowrap;
}

.cars-table td {
    padding: 12px;
    border-bottom: 1px solid #f0f0f0;
    white-space: nowrap;
}

.cars-table .car-row:hover {
    background: #f8f9ff;
}

.cars-table .car-row:nth-child(even) {
    background: #fafbff;
}

.cars-table .car-row:nth-child(even):hover {
    background: #f0f2ff;
}

.no-data {
    text-align: center;
    padding: 60px 20px;
    color: #888;
}

.no-data p {
    font-size: 1.1rem;
    margin: 0;
}

/* Responsive table */
@media (max-width: 768px) {
    .table-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .filter-input {
        max-width: none;
    }
    
    .cars-table {
        font-size: 12px;
    }
    
    .cars-table th,
    .cars-table td {
        padding: 8px;
    }
    
    .tab-content {
        padding: 20px;
    }
    
    .dealer-info-card {
        padding: 20px;
        margin-left: -48px;
        margin-right: -48px;
    }
    
    .info-grid {
        grid-template-columns: 1fr;
    }
    
    .dealer-map {
        height: 250px;
    }
}

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

.htmx-indicator {
    display: inline-block;
    animation: spin 1s linear infinite;
}

.htmx-indicator::before {
    content: "⟳";
}

/* Modal styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 20px;
}

.modal-content {
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    max-width: 800px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    padding: 20px 25px 15px;
    border-bottom: 1px solid #eee;
    position: relative;
    background: linear-gradient(135deg, #f8f9ff 0%, #f0f2ff 100%);
    border-radius: 12px 12px 0 0;
}

.modal-header h3 {
    margin: 0 0 5px 0;
    font-size: 1.4rem;
    color: #333;
}

.modal-header h4 {
    margin: 0;
    font-size: 1.1rem;
    color: #666;
    font-weight: normal;
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 20px;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    padding: 5px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.modal-close:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

.modal-body {
    padding: 25px;
}

.score-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 30px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
}

.score-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
}

.score-item label {
    font-weight: 600;
    color: #555;
}

.score-item span {
    font-weight: 700;
    color: #333;
}

.cars-breakdown {
    margin-bottom: 30px;
}

.cars-breakdown h5 {
    margin: 0 0 15px 0;
    font-size: 1.1rem;
    color: #333;
}

.car-scores-table {
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
}

.car-score-header {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr 1fr 1fr;
    gap: 10px;
    padding: 12px 15px;
    background: #f1f3f4;
    font-weight: 600;
    color: #555;
    border-bottom: 1px solid #ddd;
}

.car-score-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr 1fr 1fr;
    gap: 10px;
    padding: 12px 15px;
    border-bottom: 1px solid #eee;
    align-items: center;
}

.car-score-row:last-child {
    border-bottom: none;
}

.car-score-row:hover {
    background-color: #f9f9f9;
}

.car-details {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.car-details span {
    font-weight: 500;
}

.car-details small {
    color: #666;
    font-size: 0.85em;
}

.final-score {
    font-weight: 700;
    color: #4CAF50;
}

.scoring-explanation {
    background: #f0f8ff;
    padding: 20px;
    border-radius: 8px;
    border-left: 4px solid #2196F3;
}

.scoring-explanation h5 {
    margin: 0 0 15px 0;
    color: #1976D2;
}

.scoring-explanation ul {
    margin: 0;
    padding-left: 20px;
}

.scoring-explanation li {
    margin-bottom: 8px;
    color: #333;
}

.scoring-explanation strong {
    color: #1976D2;
}

/* Clickable score styling */
.score-value.clickable {
    cursor: pointer;
    color: #0056b3;
    border: none;
    transition: color 0.2s;
}

.score-value.clickable:hover {
    color: #357abd;
}

/* Responsive modal */
@media (max-width: 768px) {
    .modal-overlay {
        padding: 10px;
    }
    
    .modal-content {
        max-height: 95vh;
    }
    
    .modal-header {
        padding: 15px 20px 10px;
    }
    
    .modal-body {
        padding: 20px;
    }
    
    .score-summary {
        grid-template-columns: 1fr;
        gap: 10px;
        padding: 15px;
    }
    
    .car-score-header,
    .car-score-row {
        grid-template-columns: 2fr 0.8fr 0.8fr 0.8fr 0.8fr 1fr;
        gap: 5px;
        padding: 10px;
        font-size: 0.9em;
    }
    
    .car-details {
        font-size: 0.85em;
    }
    
    .scoring-explanation {
        padding: 15px;
    }
    
    /* Responsive navigation */
    .compact-nav .nav-content {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }
    
    .compact-nav .nav-right {
        width: 100%;
        justify-content: center;
    }
    
    .compact-nav .user-info {
        gap: 10px;
    }
    
    .compact-nav .user-greeting {
        font-size: 0.8rem;
    }
}

/* Configuration Summary in Modal */
.config-summary {
    margin-top: 1.5rem;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #e9ecef;
}

.config-summary h6 {
    margin: 0 0 0.5rem 0;
    color: #495057;
    font-size: 0.9rem;
    font-weight: 600;
}

.config-summary p {
    margin: 0 0 0.75rem 0;
    font-size: 0.85rem;
}

.config-details {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.config-disabled {
    background: #fff3cd;
    color: #856404;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    border: 1px solid #ffeaa7;
}

/* Enhanced mobile styles for smaller screens (phones) */
@media (max-width: 480px) {
    .compact-nav {
        padding: 10px 0;
    }
    
    .compact-nav .container {
        padding: 0 10px;
    }
    
    .compact-nav .logo {
        font-size: 2.1rem;
    }
    
    .compact-nav .tagline {
        font-size: 0.8rem;
        max-width: 100%;
    }
    
    .compact-nav .user-greeting {
        display: none; /* Hide greeting on very small screens to save space */
    }
    
    .compact-nav .admin-link,
    .compact-nav .logout-btn {
        padding: 5px 10px;
        font-size: 0.8rem;
    }
    
    /* Ensure location filter elements stack properly */
    .location-filter h3 {
        font-size: 1rem;
    }
    
    .location-filter-controls {
        grid-template-columns: 1fr !important;
    }
    
    .location-filter .location-btn,
    .location-filter select,
    .location-filter .clear-location-btn {
        font-size: 14px;
        padding: 12px;
        width: 100% !important;
    }
    
    /* Adjust search form for small screens */
    .search-form .form-group label {
        font-size: 0.9rem;
    }
    
    .search-form .form-group select,
    .search-form .form-group input {
        font-size: 16px; /* Prevent zoom on iOS */
    }
    
    /* Full-width cards on mobile portrait - only affect left/right margins */
    .results-container {
        margin-left: -15px;
        margin-right: -15px;
    }
    
    .dealers-grid {
        padding-left: 15px;
        padding-right: 15px;
        grid-template-columns: 1fr;
    }
    
    .dealer-card {
        margin-left: -48px;
        margin-right: -48px;
        border-radius: 0;
    }
    
    .location-filter {
        margin-left: -15px;
        margin-right: -15px;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }
}
