/* styles/main.css - Diseño mejorado mobile-first */

:root {
    --primary: #1e3a8a;      /* Azul más profundo */
    --primary-light: #3b82f6;
    --secondary: #059669;     /* Verde más vibrante */
    --secondary-light: #10b981;
    --accent: #dc2626;        /* Rojo para precios altos */
    --accent-light: #ef4444;
    
    --light: #f8fafc;
    --white: #ffffff;
    --dark: #1e293b;
    --gray: #64748b;
    --gray-light: #e2e8f0;
    --gray-dark: #334155;
    
    --success: #059669;
    --warning: #d97706;
    --danger: #dc2626;
    
    /* Gradientes */
    --gradient-primary: linear-gradient(135deg, var(--primary), var(--primary-light));
    --gradient-secondary: linear-gradient(135deg, var(--secondary), var(--secondary-light));
    --gradient-bg: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    
    /* Sombras mejoradas */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07), 0 2px 4px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1), 0 4px 6px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.1), 0 10px 10px rgba(0, 0, 0, 0.04);
    
    /* Transiciones */
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-fast: all 0.15s ease-out;
}

/* Reset y base - Mobile First */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--gradient-bg);
    color: var(--dark);
    line-height: 1.6;
    font-size: 16px;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Header mejorado */
header {
    background: var(--white);
    border-bottom: 1px solid var(--gray-light);
    padding: 1.5rem 1rem;
    text-align: center;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow-sm);
}

header h1 {
    font-size: 1.875rem;
    font-weight: 800;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
    letter-spacing: -0.025em;
}

.subtitle {
    color: var(--gray);
    font-size: 1rem;
    font-weight: 500;
    max-width: 600px;
    margin: 0 auto;
}

/* Layout principal */
main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
    min-height: calc(100vh - 200px);
}

/* Contenedor de búsqueda mejorado */
.search-container {
    background: var(--white);
    border-radius: 16px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--gray-light);
}

/* Botón de ubicación mejorado */
.location-options {
    margin-bottom: 1.5rem;
}

.location-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 1rem;
    border: 2px solid var(--primary-light);
    background: var(--gradient-primary);
    color: var(--white);
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    box-shadow: var(--shadow-md);
}

.location-btn:hover, .location-btn:focus {
    transform: translateY(-2px);
    box-shadow: var(--shadow-xl);
}

.location-btn:active {
    transform: translateY(0);
}

.btn-icon {
    font-size: 1.25rem;
}

/* Caja de búsqueda mejorada */
.search-box {
    position: relative;
    margin-bottom: 1.5rem;
    display: flex; /* Añadido para alinear input y botón */
    flex-wrap: wrap; /* Permitir que el botón salte de línea en móviles pequeños */
    gap: 0.75rem; /* Espacio entre input y botón */
}

#location-input {
    width: 100%;
    padding: 1rem 1.25rem;
    border: 2px solid var(--gray-light);
    border-radius: 12px;
    font-size: 1rem;
    background: var(--white);
    transition: var(--transition);
    outline: none;
    flex-grow: 1; /* El input tomará todo el espacio disponible */
    margin-bottom: 0; /* Eliminar margen inferior si se usa flexbox */
}

#location-input:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1), var(--shadow-md); /* Añadir una sombra sutil */
}

#location-input::placeholder {
    color: var(--gray);
}

.search-btn {
    width: 100%;
    padding: 1rem 1.5rem;
    background: var(--gradient-secondary);
    color: var(--white);
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-md);
    flex-shrink: 0; /* El botón no se encogerá */
    min-width: 120px; /* Asegurar un tamaño mínimo para el botón */
}

.search-btn:hover, .search-btn:focus {
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

/* Autocompletado mejorado */
.autocomplete-results {
    position: absolute;
    top: calc(100% - 0.75rem);
    left: 0;
    right: 0;
    background: var(--white);
    border: 2px solid var(--gray-light);
    border-top: none;
    border-radius: 0 0 12px 12px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: var(--shadow-lg);
}

.autocomplete-item {
    padding: 0.875rem 1.25rem;
    cursor: pointer;
    font-size: 0.875rem;
    transition: var(--transition-fast);
    border-bottom: 1px solid var(--gray-light);
}

.autocomplete-item:hover {
    background-color: var(--light);
}

.autocomplete-item:last-child {
    border-bottom: none;
    border-radius: 0 0 12px 12px;
}

/* Filtros mejorados */
.filters {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.filter-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--gray-dark);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.filter-select {
    padding: 0.875rem 1rem;
    border: 2px solid var(--gray-light);
    border-radius: 10px;
    background: var(--white);
    font-size: 0.875rem;
    color: var(--dark);
    cursor: pointer;
    transition: var(--transition);
    outline: none;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpolyline points='6,9 12,15 18,9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.875rem center;
    background-size: 16px;
    padding-right: 2.5rem;
}

.filter-select:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
}

/* Loading spinner mejorado */
.loading-spinner {
    border: 3px solid var(--gray-light);
    border-radius: 50%;
    border-top: 3px solid var(--primary-light);
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 2rem auto 0.5rem auto; /* Ajustar margen para el mensaje */
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Mensaje de carga */
.loading-message {
    text-align: center;
    color: var(--gray);
    font-size: 0.9rem;
    margin-top: 0.5rem;
    margin-bottom: 2rem;
    font-weight: 500;
}


/* Contenedor de resultados */
.results-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Tarjetas de gasolineras rediseñadas */
.station-card {
    background: var(--white);
    border-radius: 16px;
    padding: 1.25rem;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--gray-light);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.station-card:hover {
    box-shadow: var(--shadow-xl);
    transform: translateY(-4px);
}

/* Tarjeta destacada para precios top */
.station-card--featured {
    border: 2px solid var(--secondary);
    background: linear-gradient(135deg, var(--white) 0%, #f0fdf4 100%);
}

.station-card--featured::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--gradient-secondary);
}

.price-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    background: var(--gradient-secondary);
    color: var(--white);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    margin-bottom: 0.75rem;
    box-shadow: var(--shadow-sm);
}

.station-header h3 {
    font-size: 1.25rem; /* Ligeramente más grande */
    font-weight: 800; /* Más audaz */
    color: var(--primary); /* Mantener el color primary, es fuerte */
    margin-bottom: 0.25rem;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-clamp: 2;
    overflow: hidden;
}

.station-address {
    color: var(--gray);
    font-size: 0.8rem;
    margin-bottom: 1rem;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-clamp: 2;
    overflow: hidden;
}

/* Precios de combustible rediseñados */
.fuel-prices {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.fuel-price {
    background: var(--light);
    border-radius: 12px;
    padding: 1rem;
    text-align: center;
    transition: var(--transition-fast);
    border: 2px solid transparent;
}

.fuel-price--primary {
    background: var(--gradient-secondary);
    color: var(--white);
    box-shadow: var(--shadow-md);
}

.fuel-price--secondary {
    background: var(--light);
    color: var(--dark);
    border: 1px solid var(--gray-light);
}

.fuel-price--secondary:hover {
    border-color: var(--primary-light);
    transform: translateY(-1px);
}

.fuel-type {
    font-size: 0.75rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    opacity: 0.9;
}

.fuel-price--primary .fuel-type {
    color: rgba(255, 255, 255, 0.9);
}

.price-value {
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: -0.025em;
}

.fuel-price--primary .price-value {
    font-size: 1.125rem;
    color: var(--white);
}

/* Footer de tarjeta mejorado */
.station-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding-top: 1rem;
    border-top: 1px solid var(--gray-light);
}

.station-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex: 1;
}

.distance {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.update {
    font-size: 0.75rem;
    color: var(--gray);
}

.map-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    background: var(--gradient-primary);
    color: var(--white);
    text-decoration: none;
    border-radius: 10px;
    font-size: 0.8rem;
    font-weight: 600;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
    white-space: nowrap;
}

.map-btn:hover, .map-btn:focus {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* Estadísticas de búsqueda */
.search-stats {
    background: var(--white);
    border-radius: 16px;
    padding: 1.5rem;
    margin-top: 1rem;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--gray-light);
}

.search-stats h4 {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 1rem;
}

.stat-item {
    text-align: center;
    padding: 0.75rem;
    background: var(--light);
    border-radius: 10px;
    border: 1px solid var(--gray-light);
}

.stat-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--gray);
    margin-bottom: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-value {
    font-size: 1rem;
    font-weight: 800;
    color: var(--dark);
}

.stat-value--min {
    color: var(--success);
}

.stat-value--max {
    color: var(--danger);
}

.stats-note {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    color: #92400e;
    padding: 0.875rem;
    border-radius: 10px;
    font-size: 0.875rem;
    text-align: center;
    border: 1px solid #fbbf24;
}

/* Estados especiales mejorados */
.no-results,
.error {
    text-align: center;
    padding: 2rem 1.5rem;
    background: var(--white);
    border-radius: 16px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--gray-light);
}

.no-results h3 {
    color: var(--primary);
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
}

.no-results p {
    color: var(--gray);
    font-size: 0.875rem;
    line-height: 1.6;
    margin-bottom: 1.5rem;
}

.placeholder-actions {
    display: flex;
    justify-content: center;
    gap: 1rem; /* Espacio entre los botones */
    flex-wrap: wrap; /* Permitir que los botones salten de línea */
}

.placeholder-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.875rem 1.5rem;
    background: var(--gradient-primary);
    color: var(--white);
    border: none;
    border-radius: 12px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-md);
}

.placeholder-btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

.error {
    border-left: 4px solid var(--danger);
    background: linear-gradient(135deg, #fef2f2 0%, var(--white) 100%);
}

.error h3 {
    color: var(--danger);
    font-size: 1.125rem;
    margin-bottom: 0.75rem;
}

.error p {
    color: var(--gray-dark);
    margin-bottom: 1rem;
}

.error-suggestions {
    background: var(--light);
    padding: 1rem;
    border-radius: 10px;
    text-align: left;
    max-width: 300px;
    margin: 0 auto;
}

.error-suggestions ul {
    list-style: none;
    padding: 0;
    margin: 0.5rem 0 0 0;
}

.error-suggestions li {
    padding: 0.25rem 0;
    color: var(--gray-dark);
    font-size: 0.8rem;
}

.error-suggestions li::before {
    content: '💡 ';
    margin-right: 0.5rem;
}

/* Feedback de búsqueda */
.search-feedback {
    text-align: center;
    margin-top: 1rem;
    padding: 0.875rem 1rem;
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
    border-radius: 10px;
    color: var(--primary);
    font-style: italic;
    font-size: 0.875rem;
    font-weight: 500;
    border: 1px solid #93c5fd;
}

/* Footer mejorado */
footer {
    background: var(--white);
    border-top: 1px solid var(--gray-light);
    padding: 2rem 1rem;
    text-align: center;
    margin-top: 3rem;
    color: var(--gray);
    font-size: 0.8rem;
    line-height: 1.6;
    box-shadow: var(--shadow-sm);
}

footer p {
    margin-bottom: 0.5rem;
}

/* Responsive Design - Mobile First mejorado */

/* Small mobile (320px+) - ya está optimizado */

/* Large mobile (480px+) */
@media (min-width: 480px) {
    .search-container {
        padding: 2rem;
    }
    
    .search-box {
        flex-wrap: nowrap; /* En pantallas más grandes, no saltar de línea */
    }
    
    #location-input {
        flex: 1;
        margin-bottom: 0;
    }
    
    .search-btn {
        width: auto;
        min-width: 120px;
    }
    
    .filters {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
    
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Tablet (768px+) */
@media (min-width: 768px) {
    header {
        padding: 2rem 1rem;
    }
    
    header h1 {
        font-size: 2.5rem;
    }
    
    .subtitle {
        font-size: 1.125rem;
    }
    
    main {
        padding: 2rem;
    }
    
    .search-container {
        max-width: 700px;
        margin: 2rem auto;
        padding: 2.5rem;
    }
    
    .location-btn {
        max-width: 300px;
        margin: 0 auto;
    }
    
    .filters {
        grid-template-columns: repeat(3, 1fr);
        gap: 1.5rem;
    }
    
    .station-footer {
        flex-wrap: nowrap;
    }
    
    .station-info {
        flex-direction: row;
        align-items: center;
        gap: 1rem;
    }
    
    .fuel-prices {
        gap: 1rem;
    }
    
    .fuel-price {
        padding: 1.25rem;
    }
}

/* Desktop (1024px+) */
@media (min-width: 1024px) {
    .search-container {
        max-width: 800px;
        padding: 3rem;
    }
    
    .results-container {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
        gap: 1.5rem;
        align-items: start;
    }
    
    .search-stats {
        grid-column: 1 / -1;
    }
    
    .station-card {
        height: fit-content;
    }
}

/* Large desktop (1280px+) */
@media (min-width: 1280px) {
    .results-container {
        grid-template-columns: repeat(2, 1fr);
        max-width: 1000px;
        margin: 0 auto;
    }
}

/* Animaciones y transiciones suaves */
.station-card,
.search-container,
.no-results,
.error,
.search-stats {
    animation: fadeInUp 0.6s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Estados de carga */
.station-card.loading {
    opacity: 0.7;
    pointer-events: none;
}

/* Mejoras de accesibilidad */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Modo oscuro mejorado */
@media (prefers-color-scheme: dark) {
    :root {
        --light: #1e293b;
        --white: #334155;
        --dark: #f1f5f9;
        --gray: #94a3b8;
        --gray-light: #475569;
        --gray-dark: #cbd5e1;
        --primary: #3b82f6;
        --primary-light: #60a5fa;
    }
    
    body {
        background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
        color: var(--dark);
    }
    
    .search-container,
    .station-card,
    .no-results,
    .search-stats {
        background: var(--white);
        border-color: var(--gray-light);
    }
    
    header {
        background: var(--white);
        border-color: var(--gray-light);
    }
    
    .fuel-price--secondary {
        background: var(--gray-light);
        color: var(--dark);
    }

    .loading-message {
        color: var(--gray-dark);
    }
}