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

:root {
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --primary-light: #eff6ff;
    --success-color: #10b981;
    --success-light: #d1fae5;
    --background: #f9fafb;
    --card-background: #ffffff;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --text-tertiary: #9ca3af;
    --border-color: #e5e7eb;
    --border-hover: #d1d5db;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
}

/* Dark mode colors */
[data-theme="dark"] {
    --primary-color: #60a5fa;
    --primary-hover: #3b82f6;
    --primary-light: #1e3a8a;
    --success-color: #34d399;
    --success-light: #064e3b;
    --background: #0f172a;
    --card-background: #1e293b;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-tertiary: #94a3b8;
    --border-color: #334155;
    --border-hover: #475569;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.4), 0 1px 2px -1px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -2px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -4px rgba(0, 0, 0, 0.5);
}

html {
    transition: background-color 0.3s ease, color 0.3s ease;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Helvetica Neue', sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
}

/* App Container */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    width: 100%;
}

/* Header Styles */
.header {
    background: var(--card-background);
    border-bottom: 2px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    z-index: 100;
}

.header-wrapper {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.25rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 2rem;
}

.brand h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 0.125rem;
    letter-spacing: -0.025em;
}

.tagline {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    display: block;
}

/* Controls */
.controls {
    display: flex;
    gap: 1.25rem;
    align-items: flex-end;
    flex-wrap: wrap;
}

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

.control-group label {
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    line-height: 1;
    padding-left: 0.25rem;
}

/* Fuel Toggle */
.fuel-toggle {
    display: flex;
    gap: 0.375rem;
    background: var(--background);
    padding: 0.25rem;
    border-radius: 0.625rem;
    border: 1px solid var(--border-color);
    height: 42px;
}

.fuel-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1.125rem;
    border: none;
    border-radius: 0.5rem;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    height: 100%;
}

.fuel-btn:hover {
    background: var(--card-background);
    color: var(--text-primary);
}

.fuel-btn.active {
    background: var(--primary-color);
    color: white;
    box-shadow: var(--shadow-sm);
}

.fuel-btn svg {
    flex-shrink: 0;
}

/* Radius Select */
.radius-select {
    padding: 0.625rem 2.25rem 0.625rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 0.625rem;
    background: var(--card-background);
    color: var(--text-primary);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.875rem center;
    min-width: 120px;
    height: 42px;
    line-height: 1;
}

.radius-select:hover {
    border-color: var(--border-hover);
}

.radius-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-light);
}

/* Sort Toggle */
.sort-toggle {
    display: flex;
    gap: 0.375rem;
    background: var(--background);
    padding: 0.25rem;
    border-radius: 0.625rem;
    border: 1px solid var(--border-color);
    height: 42px;
}

.sort-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1.125rem;
    border: none;
    border-radius: 0.5rem;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    height: 100%;
}

.sort-btn:hover {
    background: var(--card-background);
    color: var(--text-primary);
}

.sort-btn.active {
    background: var(--primary-color);
    color: white;
    box-shadow: var(--shadow-sm);
}

.sort-btn svg {
    flex-shrink: 0;
}

/* Map Section */
.map-section {
    position: relative;
    background: var(--background);
    height: 50vh;
    min-height: 400px;
    flex-shrink: 0;
}

.map {
    width: 100%;
    height: 100%;
}

/* Map Center Crosshair */
.map-center-marker {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;
    pointer-events: none;
}

.crosshair {
    width: 20px;
    height: 20px;
    position: relative;
}

.crosshair::before,
.crosshair::after {
    content: '';
    position: absolute;
    background: var(--primary-color);
    box-shadow: 0 0 4px rgba(59, 130, 246, 0.4);
}

.crosshair::before {
    left: 50%;
    top: 0;
    width: 2px;
    height: 100%;
    transform: translateX(-50%);
}

.crosshair::after {
    top: 50%;
    left: 0;
    height: 2px;
    width: 100%;
    transform: translateY(-50%);
}

.search-area-btn {
    position: absolute;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 3rem;
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
}

.search-area-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    box-shadow: var(--shadow-lg), 0 0 0 4px var(--primary-light);
}

.search-area-btn.hidden {
    display: none;
}

/* Stations Section */
.stations-section {
    background: var(--card-background);
    border-top: 2px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex: 1;
}

.stations-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--card-background);
    flex-shrink: 0;
}

.stations-header h2 {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-primary);
}

.station-count {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Stations List */
.stations-list {
    padding: 1rem;
    flex: 1;
}

.stations-list::-webkit-scrollbar {
    width: 8px;
}

.stations-list::-webkit-scrollbar-track {
    background: var(--background);
}

.stations-list::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.stations-list::-webkit-scrollbar-thumb:hover {
    background: var(--border-hover);
}

/* Loading State */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    gap: 1rem;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.loading p {
    color: var(--text-secondary);
    font-size: 0.9375rem;
}

/* Station Card */
.station-card {
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    padding: 1.125rem;
    margin-bottom: 0.75rem;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.station-card:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.station-card:active {
    transform: translateY(0);
}

.station-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.625rem;
    gap: 1rem;
}

.station-info {
    flex: 1;
    min-width: 0;
}

.station-name {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
    line-height: 1.3;
}

.station-address {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.station-price-container {
    text-align: right;
    flex-shrink: 0;
}

.station-price {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--success-color);
    line-height: 1;
    margin-bottom: 0.25rem;
}

.station-price-label {
    font-size: 0.6875rem;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.025em;
    font-weight: 600;
}

.station-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 0.625rem;
    border-top: 1px solid var(--border-color);
    margin-top: 0.625rem;
}

.station-distance {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.no-stations {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-secondary);
}

/* Leaflet Popup Customization */
.leaflet-popup-content-wrapper {
    border-radius: 0.75rem;
    box-shadow: var(--shadow-lg);
    padding: 0.5rem;
}

.popup-content {
    padding: 0.375rem;
}

.popup-name {
    font-weight: 700;
    margin-bottom: 0.375rem;
    color: var(--text-primary);
}

.popup-price {
    color: var(--success-color);
    font-weight: 800;
    font-size: 1.25rem;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .header-wrapper {
        flex-direction: column;
        align-items: flex-start;
        padding: 1rem;
        gap: 1.25rem;
    }

    .brand {
        width: 100%;
    }

    .brand h1 {
        font-size: 1.5rem;
    }

    .controls {
        width: 100%;
        gap: 1rem;
        align-items: stretch;
    }

    .control-group {
        flex: 1;
        min-width: 0;
    }

    .control-group label {
        padding-left: 0.5rem;
    }

    .fuel-toggle,
    .sort-toggle {
        width: 100%;
        height: 44px;
    }

    .fuel-btn,
    .sort-btn {
        flex: 1;
        justify-content: center;
        font-size: 0.8125rem;
        padding: 0.5rem 0.875rem;
        gap: 0.375rem;
    }

    .radius-select {
        width: 100%;
        height: 44px;
        font-size: 0.8125rem;
    }

    .map-section {
        height: 40vh;
        min-height: 300px;
    }

    .theme-toggle-floating {
        bottom: 1rem;
        right: 1rem;
        width: 48px;
        height: 48px;
    }

    .theme-toggle-icon {
        width: 20px;
        height: 20px;
    }

    .station-card {
        padding: 1rem;
    }

    .station-price {
        font-size: 1.25rem;
    }

    .search-area-btn {
        padding: 0.625rem 1.25rem;
        font-size: 0.8125rem;
    }
}

@media (max-width: 480px) {
    .controls {
        flex-direction: column;
    }

    .control-group {
        width: 100%;
    }

    .tagline {
        font-size: 0.75rem;
    }

    .station-header {
        flex-direction: column;
        gap: 0.5rem;
    }

    .station-price-container {
        align-self: flex-end;
    }
}

/* Floating Dark Mode Toggle */
.theme-toggle-floating {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    background: var(--card-background);
    border: 2px solid var(--border-color);
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-lg);
    z-index: 1001;
}

.theme-toggle-floating:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
    transform: scale(1.1);
    box-shadow: 0 12px 24px -6px rgba(0, 0, 0, 0.3);
}

.theme-toggle-floating:active {
    transform: scale(0.95);
}

.theme-toggle-icon {
    width: 24px;
    height: 24px;
    color: var(--text-secondary);
    transition: all 0.3s;
}

.theme-toggle-floating:hover .theme-toggle-icon {
    color: white;
}

/* Dark mode map adjustments */
[data-theme="dark"] .leaflet-tile {
    filter: brightness(0.6) invert(1) contrast(3) hue-rotate(200deg) saturate(0.3) brightness(0.7);
}

[data-theme="dark"] .leaflet-control-zoom a {
    background-color: var(--card-background);
    color: var(--text-primary);
    border-color: var(--border-color);
}

[data-theme="dark"] .leaflet-control-zoom a:hover {
    background-color: var(--background);
}

[data-theme="dark"] .leaflet-popup-content-wrapper {
    background: var(--card-background);
    color: var(--text-primary);
}

[data-theme="dark"] .leaflet-popup-tip {
    background: var(--card-background);
}

/* Price Submission Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-content {
    background: var(--card-background);
    border-radius: 16px;
    width: 100%;
    max-width: 500px;
    box-shadow: var(--shadow-lg);
    max-height: 90vh;
    overflow-y: auto;
}

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

.modal-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 2rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all 0.2s;
}

.modal-close:hover {
    background: var(--background);
    color: var(--text-primary);
}

.modal-body {
    padding: 1.5rem;
}

.modal-station-name {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.modal-description {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 1.5rem;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.form-group input[type="number"] {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    background: var(--background);
    color: var(--text-primary);
    transition: all 0.2s;
}

.form-group input[type="number"]:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.form-note {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: var(--primary-light);
    border-radius: 8px;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.form-note svg {
    flex-shrink: 0;
    margin-top: 2px;
}

.modal-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

.btn-primary,
.btn-secondary {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

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

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.btn-secondary {
    background: var(--background);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

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

.submission-message {
    display: none;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    border-radius: 8px;
    font-size: 0.9375rem;
    font-weight: 500;
    margin-top: 1rem;
}

.submission-message.success {
    background: var(--success-light);
    color: var(--success-color);
}

.submission-message.error {
    background: #fee;
    color: #c00;
}

.popup-update-btn {
    margin-top: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    transition: all 0.2s;
}

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

/* Tablet and Desktop */
@media (min-width: 1024px) {
    .header-wrapper {
        padding: 1.5rem 2rem;
    }

    .brand h1 {
        font-size: 2rem;
    }

    .stations-section {
        max-height: 40vh;
    }

    .stations-list {
        padding: 1.5rem;
    }

    .station-card {
        padding: 1.25rem;
    }
}
