/* =========================================
   VARIABLES & THEMING (Dark Mode Default)
   ========================================= */
   :root {
    --bg-color: #0f172a;
    --bg-gradient-start: #0f172a;
    --bg-gradient-end: #1e293b;
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    
    --accent-primary: #3b82f6;
    --accent-hover: #2563eb;
    --accent-glow: rgba(59, 130, 246, 0.4);
    
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --error-color: #ef4444;
    
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    
    --card-bg: rgba(30, 41, 59, 0.8);
    --card-hover-bg: rgba(51, 65, 85, 0.9);
    
    --input-bg: rgba(15, 23, 42, 0.6);
    --input-border: rgba(255, 255, 255, 0.2);
    --input-focus: #3b82f6;
    
    --font-main: 'Inter', sans-serif;
    --border-radius-lg: 16px;
    --border-radius-md: 12px;
    --border-radius-sm: 8px;
    
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
}

/* =========================================
   RESET & BASE STYLES
   ========================================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    line-height: 1.5;
}

/* Dynamic animated background */
.background-effect {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: radial-gradient(circle at 15% 50%, rgba(59, 130, 246, 0.15), transparent 25%),
                radial-gradient(circle at 85% 30%, rgba(16, 185, 129, 0.1), transparent 25%);
    z-index: -1;
    pointer-events: none;
}

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

.hidden {
    display: none !important;
}

/* =========================================
   TYPOGRAPHY
   ========================================= */
h1, h2, h3, h4 {
    font-weight: 700;
    line-height: 1.2;
}

h2 {
    font-size: 1.75rem;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

/* =========================================
   UTILITIES (Glassmorphism)
   ========================================= */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--glass-shadow);
}

/* =========================================
   HEADER
   ========================================= */
.header {
    padding: 2rem 0;
    text-align: center;
    margin-bottom: 2rem;
}

.logo {
    font-size: 2.5rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    text-shadow: 0 0 20px var(--accent-glow);
}

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

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

/* =========================================
   MAIN CONTENT
   ========================================= */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 3rem;
}

/* --- Search Section --- */
.search-section {
    padding: 2rem;
    position: relative;
    overflow: hidden;
}

.search-section::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--accent-primary), var(--success-color));
}

.search-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
}

.location-row {
    width: 100%;
}

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

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

.flex-grow {
    flex: 1 1 100%;
}

label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
}

/* Inputs & Selects */
input[type="text"], select {
    width: 100%;
    padding: 0.875rem 1rem;
    background-color: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: var(--border-radius-md);
    color: var(--text-primary);
    font-size: 1rem;
    font-family: inherit;
    transition: all var(--transition-normal);
    outline: none;
}

input[type="text"]::placeholder {
    color: rgba(148, 163, 184, 0.5);
}

input[type="text"]:focus, select:focus {
    border-color: var(--input-focus);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

/* Custom Select Wrapper */
.custom-select-wrapper {
    position: relative;
    width: 100%;
}

.custom-select-wrapper select {
    appearance: none; /* Rimuove styling di default del browser */
    cursor: pointer;
    padding-right: 2.5rem;
}

/* Dropdown color specifically for options in dark mode */
.custom-select-wrapper select option {
    background-color: var(--bg-color);
    color: var(--text-primary);
}

.select-icon {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    pointer-events: none;
}

/* Input with button (Location field) */
.input-with-button {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.input-with-button input {
    flex: 1;
}

.btn-icon {
    background: var(--glass-bg);
    border: 1px solid var(--input-border);
    color: var(--accent-primary);
    width: 46px;
    height: 46px;
    border-radius: var(--border-radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: all var(--transition-fast);
}

.btn-icon:hover {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
    box-shadow: 0 0 15px var(--accent-glow);
}

.status-text {
    font-size: 0.8rem;
    color: var(--text-secondary);
    min-height: 1rem;
}

.status-text.text-success { color: var(--success-color); }
.status-text.text-error { color: var(--error-color); }

/* Range Slider */
.slider {
    -webkit-appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--input-bg);
    outline: none;
    margin-top: 10px;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--accent-primary);
    cursor: pointer;
    box-shadow: 0 0 10px var(--accent-glow);
    transition: all var(--transition-fast);
}

.slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

/* Primary Button */
.btn-primary {
    background: linear-gradient(135deg, var(--accent-primary), #6366f1);
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: var(--border-radius-md);
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    transition: all var(--transition-normal);
    box-shadow: 0 4px 15px var(--accent-glow);
    margin-top: 1rem;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.6);
}

.btn-primary:active {
    transform: translateY(1px);
}

/* --- Results Section --- */
.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.results-count {
    color: var(--text-secondary);
    font-size: 0.9rem;
    background: var(--glass-bg);
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    border: 1px solid var(--glass-border);
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 2rem;
}

/* Loading & Error States */
#loading-spinner {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
}

.spinner {
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top: 4px solid var(--accent-primary);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

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

.error-panel {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--error-color);
    padding: 1.5rem;
    border-radius: var(--border-radius-md);
    display: flex;
    align-items: center;
    gap: 1rem;
    font-weight: 500;
}

/* =========================================
   STATION CARDS
   ========================================= */
.station-card {
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    transition: all var(--transition-normal);
    animation: slideUpFade 0.5s ease forwards;
    opacity: 0;
    transform: translateY(20px);
    /* Calculate delay based on standard CSS variable */
    animation-delay: calc(var(--animation-order) * 0.1s);
}

.station-card:hover {
    transform: translateY(-5px) scale(1.02);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
    border-color: rgba(255, 255, 255, 0.2);
    background: var(--card-hover-bg);
}

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

.card-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.rank-badge {
    background: linear-gradient(135deg, var(--accent-primary), #6366f1);
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.2rem;
    box-shadow: 0 0 15px var(--accent-glow);
}

.station-card:nth-child(1) .rank-badge {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    box-shadow: 0 0 15px rgba(245, 158, 11, 0.4);
}
.station-card:nth-child(2) .rank-badge {
    background: linear-gradient(135deg, #94a3b8, #64748b);
    box-shadow: 0 0 15px rgba(148, 163, 184, 0.4);
}
.station-card:nth-child(3) .rank-badge {
    background: linear-gradient(135deg, #b45309, #92400e);
    box-shadow: 0 0 15px rgba(180, 83, 9, 0.4);
}

.station-name {
    flex: 1;
    font-size: 1.25rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.fuel-type-badge {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    font-weight: 600;
}

.card-body {
    flex: 1;
}

.price-display {
    display: flex;
    align-items: baseline;
    justify-content: center;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--border-radius-sm);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.currency {
    font-size: 1.5rem;
    color: var(--text-secondary);
    margin-right: 0.25rem;
}

.price-value {
    font-size: 3rem;
    font-weight: 700;
    color: var(--success-color);
    line-height: 1;
    text-shadow: 0 0 20px rgba(16, 185, 129, 0.3);
}

.price-unit {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-left: 0.25rem;
}

.station-details {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.station-details p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.station-details i {
    color: var(--accent-primary);
    margin-top: 0.25rem;
    width: 16px;
    text-align: center;
}

.service-type i {
    color: var(--warning-color);
}

.card-footer {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.last-update {
    font-size: 0.8rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-secondary {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
    padding: 0.75rem;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all var(--transition-fast);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--text-primary);
}

/* =========================================
   FOOTER
   ========================================= */
footer {
    margin-top: 3rem;
    padding: 2rem 0;
    text-align: center;
    border-top: 1px solid var(--glass-border);
    background: rgba(15, 23, 42, 0.8);
}

footer p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* =========================================
   RESPONSIVE DESIGN
   ========================================= */
@media (max-width: 768px) {
    .options-row {
        grid-template-columns: 1fr;
    }
    
    .price-value {
        font-size: 2.5rem;
    }
    
    .logo {
        font-size: 2rem;
    }
}
