/**
 * Estilos del Dashboard Meteorológico WH1080
 * Extraído de index.php para mejor organización
 */

:root {
    --primary-bg: #0a0a0a;
    --card-bg: #1a1a1a;
    --card-hover: #252525;
    --accent: #00d4ff;
    --accent-2: #ff6b6b;
    --accent-3: #4ecdc4;
    --accent-4: #45b7d1;
    --accent-5: #a55eea;
    --accent-6: #26de81;
    --accent-7: #ffa726;
    --text-primary: #ffffff;
    --text-secondary: #b0b0b0;
    --border: #333;
    --success: #00ff88;
    --warning: #ffb347;
    --danger: #ff4757;
}

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

body {
    font-family: 'Inter', sans-serif;
    background: linear-gradient(135deg, var(--primary-bg) 0%, #1a1a2e 100%);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

/* HEADER STYLES */
.header {
    background: linear-gradient(135deg, var(--card-bg) 0%, #2d2d2d 100%);
    border-bottom: 1px solid var(--border);
    padding: 1.5rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem;
}

.header-title {
    text-align: center;
    margin-bottom: 1rem;
}

.station-title {
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent);
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.header-status {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.status-left {
    flex: 1;
}

.status-right {
    flex: 1;
    display: flex;
    justify-content: flex-end;
}

.last-reading {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    background: rgba(0, 212, 255, 0.1);
    border: 1px solid var(--accent);
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.last-reading i {
    color: var(--accent);
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    background: rgba(0, 255, 136, 0.1);
    border: 1px solid var(--success);
    font-size: 0.9rem;
    transition: all 0.4s ease;
}

.status-indicator.loading {
    background: rgba(255, 179, 71, 0.1);
    border-color: var(--warning);
}

.status-indicator.error {
    background: rgba(255, 71, 87, 0.1);
    border-color: var(--danger);
}

.status-indicator i {
    transition: transform 0.3s ease;
}

.status-indicator.loading i {
    animation: spin 1s linear infinite;
    color: var(--warning);
}

.status-indicator.error i {
    color: var(--danger);
}

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

.header-menu {
    border-top: 1px solid var(--border);
    padding-top: 1rem;
}

.main-menu {
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.menu-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: var(--card-bg);
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 8px;
    border: 1px solid var(--border);
    transition: all 0.3s ease;
    font-weight: 500;
}

.menu-btn:hover {
    background: var(--card-hover);
    color: var(--text-primary);
    border-color: var(--accent);
    transform: translateY(-2px);
}

.menu-btn.active {
    background: var(--accent);
    color: var(--primary-bg);
    border-color: var(--accent);
}

/* MAIN CONTAINER */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

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

/* WEATHER CARDS */
.weather-card.temperature-card {
    grid-column: span 2;
    max-width: none;
}

.weather-card {
    background: linear-gradient(135deg, var(--card-bg) 0%, rgba(26, 26, 26, 0.8) 100%);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    backdrop-filter: blur(10px);
    position: relative;
    overflow: hidden;
}

.weather-card:hover {
    transform: translateY(-5px);
    border-color: var(--accent);
    box-shadow: 0 10px 25px rgba(0, 212, 255, 0.15);
}

.weather-card.updating {
    animation: pulse-update 1.5s ease-in-out;
}

@keyframes pulse-update {
    0% { transform: scale(1); }
    50% { transform: scale(1.02); }
    100% { transform: scale(1); }
}

.card-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.card-header i {
    font-size: 1.2rem;
    color: var(--accent);
}

.card-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.card-content {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

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

/* SENSOR VALUES */
.sensor-value {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    border: 1px solid transparent;
    transition: all 0.3s ease;
    position: relative;
}

.sensor-value:hover {
    border-color: var(--accent);
    background: rgba(0, 212, 255, 0.1);
}

.sensor-value.dew-point:hover {
    border-color: var(--accent-5);
    background: rgba(165, 94, 234, 0.1);
}

.sensor-value.wind-chill:hover {
    border-color: var(--accent-6);
    background: rgba(38, 222, 129, 0.1);
}

.sensor-value.heat-index:hover {
    border-color: var(--accent-7);
    background: rgba(255, 167, 38, 0.1);
}

.sensor-label {
    font-weight: 500;
    color: var(--text-secondary);
}

.sensor-reading {
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--text-primary);
    transition: all 0.3s ease;
}

.sensor-reading.updating {
    color: var(--accent);
    animation: value-update 0.6s ease-in-out;
}

@keyframes value-update {
    0% { opacity: 0.7; transform: scale(0.98); }
    50% { opacity: 1; transform: scale(1.02); }
    100% { opacity: 1; transform: scale(1); }
}

/* UNIT SELECTORS */
.units-selector {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.unit-btn {
    padding: 0.4rem 0.75rem;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.unit-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 212, 255, 0.1);
}

.unit-btn.active {
    background: var(--accent);
    color: var(--primary-bg);
    border-color: var(--accent);
    transform: none;
    box-shadow: 0 0 12px rgba(0, 212, 255, 0.3);
}

/* PRESSURE TREND SECTION */
.pressure-trend-section {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.trend-title {
    text-align: center;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
}

.trend-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: rgba(0, 212, 255, 0.05);
    border: 1px solid rgba(0, 212, 255, 0.2);
    border-radius: 8px;
    transition: all 0.3s ease;
}

.trend-indicator:hover {
    background: rgba(0, 212, 255, 0.1);
    border-color: var(--accent);
}

.trend-indicator.updating {
    animation: trend-pulse 1.5s ease-in-out;
}

@keyframes trend-pulse {
    0% { background: rgba(0, 212, 255, 0.05); }
    50% { background: rgba(0, 212, 255, 0.15); }
    100% { background: rgba(0, 212, 255, 0.05); }
}

#weather-prediction-icon {
    width: 80px;
    height: 80px;
    border-radius: 8px;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
}

.trend-indicator:hover #weather-prediction-icon {
    border-color: var(--accent);
    transform: scale(1.05);
}

.trend-text {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    text-align: center;
    width: 100%;
}

#pressure-trend-status {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
}

#weather-prediction {
    font-size: 1rem;
    color: var(--text-primary);
    font-weight: 600;
}

.trend-time-selector {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
    justify-content: center;
}

.trend-time-btn {
    padding: 0.4rem 0.75rem;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    min-height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    font-weight: 500;
}

.trend-time-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 212, 255, 0.1);
    border-color: var(--accent);
}

.trend-time-btn.active {
    background: var(--accent);
    color: var(--primary-bg);
    border-color: var(--accent);
    transform: none;
    box-shadow: 0 0 8px rgba(0, 212, 255, 0.3);
}

/* WEBCAM CARD STYLES - Solución avanzada con aspect-ratio */

.webcam-container {
    width: 100%;
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    transition: all 0.3s ease;
    /* Proporción 16:9 típica de webcams */
    aspect-ratio: 16 / 9;
    min-height: 200px; /* Altura mínima garantizada */
}

.webcam-container:hover {
    border-color: var(--accent);
    box-shadow: 0 4px 12px rgba(0, 212, 255, 0.15);
}

.webcam-container iframe {
    display: block;
    width: 100%;
    height: 100%; /* Ocupa todo el contenedor automáticamente */
    border: none;
    border-radius: 8px;
}

.webcam-info {
    margin-top: 1rem;
}

.webcam-info .sensor-value {
    background: rgba(0, 212, 255, 0.05);
    border: 1px solid rgba(0, 212, 255, 0.2);
}

.webcam-info .sensor-value:hover {
    background: rgba(0, 212, 255, 0.1);
    border-color: var(--accent);
}

/* CHART CONTAINER */
.chart-container {
    grid-column: 1 / -1;
    background: linear-gradient(135deg, var(--card-bg) 0%, rgba(26, 26, 26, 0.8) 100%);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    margin-top: 1rem;
}

.chart-tabs {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.tab-btn {
    padding: 0.75rem 1.5rem;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
}

.tab-btn.active {
    background: var(--accent);
    color: var(--primary-bg);
    border-color: var(--accent);
}

.tab-btn:hover:not(.active) {
    border-color: var(--accent);
    color: var(--text-primary);
}

.chart-wrapper {
    height: 400px;
    position: relative;
}

/* RESPONSIVE DESIGN - Con aspect-ratio mejorado */
@media (max-width: 768px) {
    .weather-card.temperature-card {
        grid-column: span 1;
    }
    
    .temperature-grid {
        grid-template-columns: 1fr;
    }
    
    .header {
        position: relative;
    }
    
    .header-content {
        padding: 0 1rem;
    }
    
    .station-title {
        font-size: 1.6rem;
    }
    
    .header-status {
        flex-direction: column;
        gap: 0.75rem;
        align-items: stretch;
    }
    
    .status-left, .status-right {
        flex: none;
        display: flex;
        justify-content: center;
    }
    
    .last-reading, .status-indicator {
        padding: 0.75rem 1.25rem;
        font-size: 0.95rem;
    }
    
    .main-menu {
        gap: 0.75rem;
    }
    
    .menu-btn {
        padding: 0.75rem 1.25rem;
        font-size: 0.9rem;
        min-height: 44px;
    }
    
    .grid {
        grid-template-columns: 1fr;
        gap: 1.25rem;
    }
    
    .weather-card {
        padding: 1.25rem;
    }
    
    .sensor-value {
        padding: 1rem;
        border-radius: 10px;
    }
    
    .sensor-reading {
        font-size: 1.2rem;
    }
    
    .units-selector {
        gap: 0.75rem;
        margin-top: 1rem;
    }
    
    .unit-btn {
        flex: 1;
        padding: 0.75rem;
        font-size: 0.9rem;
        min-height: 48px;
    }

    .trend-indicator {
        gap: 0.75rem;
        padding: 1rem;
    }

    #weather-prediction-icon {
        width: 64px;
        height: 64px;
    }

    .trend-text {
        gap: 0.5rem;
    }

    #pressure-trend-status {
        font-size: 0.85rem;
    }

    #weather-prediction {
        font-size: 0.95rem;
    }

    .trend-time-selector {
        gap: 0.25rem;
    }

    .trend-time-btn {
        padding: 0.5rem 0.25rem;
        font-size: 0.75rem;
        min-height: 36px;
    }

    /* WEBCAM RESPONSIVE - Proporción ligeramente más cuadrada en móvil */
    .webcam-container {
        aspect-ratio: 16 / 10; /* Más cuadrada que 16:9 */
        min-height: 180px; /* Altura mínima mayor en móvil */
    }
    
    .chart-container {
        grid-column: 1;
        margin-top: 1.5rem;
    }
    
    .chart-wrapper {
        height: 350px;
    }
    
    .container {
        padding: 1.25rem;
    }
    
    .chart-tabs {
        gap: 0.5rem;
    }
    
    .tab-btn {
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
        min-height: 44px;
        flex: 1;
    }
}

/* Pantallas muy pequeñas */
@media (max-width: 480px) {
    .webcam-container {
        aspect-ratio: 4 / 3; /* Más cuadrada para móviles muy pequeños */
        min-height: 200px; /* Altura mínima extra */
    }
}

/* Ajustes para tablets */
@media (max-width: 1024px) and (min-width: 769px) {
    .webcam-container {
        aspect-ratio: 16 / 9; /* Proporción normal en tablet */
        min-height: 180px;
    }
}