/**
 * Predictions Page Styles
 * Sistema Predictivo - Gemelo Digital
 */

/* Variables */
:root {
    --color-valle: #22c55e;
    --color-llano: #f59e0b;
    --color-punta: #ef4444;
    --color-frost: #3b82f6;
    --color-alert-critical: #dc2626;
    --color-alert-warning: #f59e0b;
    --color-alert-info: #3b82f6;
}

/* Page Layout */
.predictions-page {
    padding: 1rem;
    overflow-y: auto;
}

/* Summary Cards */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.summary-card {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    border-radius: 12px;
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: transform 0.2s, box-shadow 0.2s;
}

.summary-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.summary-card .card-icon {
    font-size: 2.5rem;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
}

.summary-card .card-content {
    flex: 1;
}

.summary-card .card-label {
    font-size: 0.85rem;
    color: #94a3b8;
    margin-bottom: 0.25rem;
}

.summary-card .card-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: #f1f5f9;
}

.summary-card .card-detail {
    font-size: 0.8rem;
    color: #64748b;
    margin-top: 0.25rem;
}

/* Card variants */
.summary-card.weather .card-icon { background: linear-gradient(135deg, #3b82f6, #1d4ed8); }
.summary-card.demand .card-icon { background: linear-gradient(135deg, #f59e0b, #d97706); }
.summary-card.alerts .card-icon { background: linear-gradient(135deg, #ef4444, #dc2626); }
.summary-card.tariff .card-icon { background: linear-gradient(135deg, #22c55e, #16a34a); }

/* Predictions Grid */
.predictions-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}

/* Prediction Panels */
.prediction-panel {
    background: #1e293b;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.prediction-panel .panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.prediction-panel .panel-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: #f1f5f9;
    margin: 0;
}

.prediction-panel .panel-source,
.prediction-panel .panel-update {
    font-size: 0.75rem;
    color: #64748b;
}

.prediction-panel .panel-content {
    padding: 1rem 1.25rem;
}

/* Weather Panel */
.weather-details {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.weather-stat {
    text-align: center;
}

.weather-stat .stat-label {
    display: block;
    font-size: 0.75rem;
    color: #64748b;
    margin-bottom: 0.25rem;
}

.weather-stat .stat-value {
    font-size: 1.25rem;
    font-weight: 600;
    color: #f1f5f9;
}

.weather-stat .stat-value.frost {
    color: var(--color-frost);
}

/* Demand Panel */
.demand-zones {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.zone-bar {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.zone-item {
    flex: 1;
    min-width: 100px;
    padding: 0.75rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    text-align: center;
}

.zone-item .zone-name {
    font-size: 0.75rem;
    color: #94a3b8;
    margin-bottom: 0.25rem;
}

.zone-item .zone-demand {
    font-size: 1rem;
    font-weight: 600;
    color: #f1f5f9;
}

/* Alerts Panel */
.alerts-list {
    max-height: 300px;
    overflow-y: auto;
}

.alert-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    border-left: 3px solid;
}

.alert-item.critical { border-left-color: var(--color-alert-critical); }
.alert-item.warning { border-left-color: var(--color-alert-warning); }
.alert-item.info { border-left-color: var(--color-alert-info); }

.alert-item .alert-icon {
    font-size: 1.25rem;
    width: 30px;
    text-align: center;
}

.alert-item .alert-content {
    flex: 1;
}

.alert-item .alert-title {
    font-weight: 600;
    color: #f1f5f9;
    font-size: 0.9rem;
}

.alert-item .alert-message {
    font-size: 0.8rem;
    color: #94a3b8;
    margin-top: 0.25rem;
}

.alert-item .alert-action {
    font-size: 0.75rem;
    color: #64748b;
    font-style: italic;
    margin-top: 0.5rem;
}

.alert-item .alert-time {
    font-size: 0.7rem;
    color: #475569;
    margin-top: 0.25rem;
}

.alert-placeholder,
.recommendation-placeholder {
    text-align: center;
    padding: 2rem;
    color: #64748b;
}

/* Recommendations Panel */
.recommendations-list {
    max-height: 300px;
    overflow-y: auto;
}

.recommendation-item {
    padding: 1rem;
    margin-bottom: 0.5rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.recommendation-item .rec-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.recommendation-item .rec-title {
    font-weight: 600;
    color: #f1f5f9;
}

.recommendation-item .rec-priority {
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    text-transform: uppercase;
}

.recommendation-item .rec-priority.high { background: #ef4444; color: white; }
.recommendation-item .rec-priority.medium { background: #f59e0b; color: white; }
.recommendation-item .rec-priority.low { background: #22c55e; color: white; }

.recommendation-item .rec-description {
    font-size: 0.85rem;
    color: #94a3b8;
    margin-bottom: 0.75rem;
}

.recommendation-item .rec-action {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.recommendation-item .rec-savings {
    font-size: 0.8rem;
    color: #22c55e;
}

.recommendation-item .btn-apply {
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    border: none;
    border-radius: 6px;
    color: white;
    cursor: pointer;
    transition: opacity 0.2s;
}

.recommendation-item .btn-apply:hover {
    opacity: 0.9;
}

.recommendation-item .btn-apply:disabled {
    background: #475569;
    cursor: not-allowed;
}

/* Tariff Panel */
.tariff-legend {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: #94a3b8;
}

.legend-item::before {
    content: '';
    width: 12px;
    height: 12px;
    border-radius: 3px;
}

.legend-item.valle::before { background: var(--color-valle); }
.legend-item.llano::before { background: var(--color-llano); }
.legend-item.punta::before { background: var(--color-punta); }

.optimal-hours {
    margin-top: 1rem;
    padding: 1rem;
    background: rgba(34, 197, 94, 0.1);
    border-radius: 8px;
    border: 1px solid rgba(34, 197, 94, 0.2);
}

.optimal-hours h4 {
    font-size: 0.85rem;
    color: #22c55e;
    margin: 0 0 0.5rem 0;
}

.hours-list {
    font-size: 0.9rem;
    color: #f1f5f9;
}

/* Predictions nav icon */
.nav-icon.predictions {
    background: linear-gradient(135deg, #8b5cf6, #6366f1);
}

/* Prediction status in top bar */
.prediction-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
}

.prediction-status .status-label {
    font-size: 0.8rem;
    color: #94a3b8;
}

.prediction-status .status-value {
    font-size: 0.85rem;
    font-weight: 600;
    color: #22c55e;
}

/* Responsive */
@media (max-width: 1200px) {
    .summary-cards {
        grid-template-columns: repeat(2, 1fr);
    }

    .predictions-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .summary-cards {
        grid-template-columns: 1fr;
    }

    .weather-details {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* 7-Day Weather Forecast Map */
.weather-forecast-map {
    background: linear-gradient(135deg, #1e3a5f 0%, #0f172a 100%);
    border-radius: 16px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border: 1px solid rgba(59, 130, 246, 0.3);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.forecast-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.forecast-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: #f1f5f9;
    margin: 0;
}

.forecast-location {
    font-size: 0.85rem;
    color: #94a3b8;
}

.forecast-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.forecast-day {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    padding: 1rem 0.75rem;
    text-align: center;
    transition: transform 0.2s, box-shadow 0.2s;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.forecast-day:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

.forecast-day.today {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.3), rgba(37, 99, 235, 0.2));
    border-color: rgba(59, 130, 246, 0.5);
}

.forecast-day .day-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: #f1f5f9;
    margin-bottom: 0.25rem;
}

.forecast-day .day-date {
    font-size: 0.7rem;
    color: #64748b;
    margin-bottom: 0.75rem;
}

.forecast-day .weather-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    display: block;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.forecast-day .temp-range {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.forecast-day .temp-max {
    font-size: 1.1rem;
    font-weight: 700;
    color: #f59e0b;
}

.forecast-day .temp-min {
    font-size: 0.9rem;
    color: #3b82f6;
}

.forecast-day .conditions {
    font-size: 0.7rem;
    color: #94a3b8;
    line-height: 1.3;
    margin-bottom: 0.5rem;
}

.forecast-day .day-details {
    font-size: 0.65rem;
    color: #64748b;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 0.5rem;
    margin-top: 0.25rem;
}

.forecast-day .detail-item {
    margin-bottom: 0.2rem;
}

.forecast-day .frost-alert {
    color: #60a5fa;
    font-weight: 500;
}

.forecast-day .demand-indicator {
    font-weight: 500;
}

/* Temperature-based card coloring */
.forecast-day.frost {
    background: linear-gradient(180deg, rgba(59, 130, 246, 0.4) 0%, rgba(30, 64, 175, 0.3) 100%);
    border-color: rgba(59, 130, 246, 0.5);
}

.forecast-day.cold {
    background: linear-gradient(180deg, rgba(56, 189, 248, 0.3) 0%, rgba(14, 116, 144, 0.2) 100%);
    border-color: rgba(56, 189, 248, 0.4);
}

.forecast-day.mild {
    background: linear-gradient(180deg, rgba(250, 204, 21, 0.2) 0%, rgba(202, 138, 4, 0.1) 100%);
    border-color: rgba(250, 204, 21, 0.3);
}

.forecast-day.warm {
    background: linear-gradient(180deg, rgba(249, 115, 22, 0.3) 0%, rgba(194, 65, 12, 0.2) 100%);
    border-color: rgba(249, 115, 22, 0.4);
}

/* Forecast legend */
.forecast-legend {
    display: flex;
    justify-content: center;
    gap: 2rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.forecast-legend .legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: #94a3b8;
}

.forecast-legend .legend-item::before {
    display: none;
}

.forecast-legend .legend-icon {
    font-size: 1.1rem;
}

/* Loading and empty states */
.forecast-loading,
.forecast-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 3rem 2rem;
    color: #64748b;
    font-size: 0.95rem;
}

.forecast-loading::before {
    content: '⏳';
    display: block;
    font-size: 2rem;
    margin-bottom: 0.5rem;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Responsive - 7-day forecast */
@media (max-width: 1200px) {
    .forecast-days {
        grid-template-columns: repeat(4, 1fr);
    }

    .forecast-day:nth-child(n+5) {
        display: none;
    }
}

@media (max-width: 768px) {
    .weather-forecast-map {
        padding: 1rem;
    }

    .forecast-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .forecast-days {
        grid-template-columns: repeat(3, 1fr);
    }

    .forecast-day:nth-child(n+4) {
        display: none;
    }

    .forecast-day .weather-icon {
        font-size: 2rem;
    }

    .forecast-legend {
        flex-wrap: wrap;
        gap: 1rem;
    }
}

@media (max-width: 480px) {
    .forecast-days {
        grid-template-columns: repeat(2, 1fr);
    }

    .forecast-day:nth-child(n+3) {
        display: none;
    }
}

/* Spain Weather Map */
.spain-weather-map {
    background: linear-gradient(135deg, #1a365d 0%, #0f172a 100%);
    border-radius: 16px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border: 1px solid rgba(59, 130, 246, 0.3);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.map-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.map-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: #f1f5f9;
    margin: 0;
}

.map-time {
    font-size: 0.75rem;
    color: #64748b;
}

.map-container {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 1.5rem;
    min-height: 350px;
}

.map-svg-wrapper {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    min-height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.map-svg-wrapper svg {
    width: 100%;
    height: 100%;
}

.map-loading {
    color: #64748b;
    font-size: 0.9rem;
}

.map-info-panel {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.location-marker {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.2), rgba(37, 99, 235, 0.1));
    border-radius: 10px;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.marker-icon {
    font-size: 2rem;
}

.marker-title {
    font-weight: 600;
    color: #f1f5f9;
    font-size: 0.95rem;
}

.marker-location {
    font-size: 0.8rem;
    color: #94a3b8;
}

.current-conditions {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    padding: 1rem;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.condition-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.5rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
}

.condition-icon {
    font-size: 1.25rem;
}

.condition-label {
    font-size: 0.7rem;
    color: #64748b;
}

.condition-value {
    font-size: 1rem;
    font-weight: 600;
    color: #f1f5f9;
}

.map-legend-temps {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    padding: 1rem;
}

.legend-title {
    font-size: 0.8rem;
    color: #94a3b8;
    margin-bottom: 0.75rem;
}

.temp-scale {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.scale-bar {
    height: 12px;
    border-radius: 6px;
    background: linear-gradient(to right,
        #3b82f6 0%,    /* -5°C cold blue */
        #60a5fa 25%,   /* 0°C light blue */
        #fcd34d 50%,   /* 10°C yellow */
        #f97316 75%,   /* 20°C orange */
        #ef4444 100%   /* 30°C red */
    );
}

.scale-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.7rem;
    color: #64748b;
}

/* SVG Map Styles */
.spain-map-svg .region {
    stroke: rgba(255, 255, 255, 0.3);
    stroke-width: 0.5;
    transition: all 0.3s ease;
}

.spain-map-svg .region:hover {
    stroke: #fff;
    stroke-width: 1;
    filter: brightness(1.2);
}

.spain-map-svg .region-label {
    font-size: 8px;
    fill: rgba(255, 255, 255, 0.7);
    pointer-events: none;
}

.spain-map-svg .location-pin {
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
    animation: pulse-pin 2s ease-in-out infinite;
}

@keyframes pulse-pin {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.spain-map-svg .city-marker {
    fill: rgba(255, 255, 255, 0.8);
}

.spain-map-svg .city-label {
    font-size: 7px;
    fill: rgba(255, 255, 255, 0.9);
    text-anchor: middle;
}

/* Responsive map */
@media (max-width: 900px) {
    .map-container {
        grid-template-columns: 1fr;
    }

    .map-svg-wrapper {
        min-height: 250px;
    }

    .map-info-panel {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .location-marker,
    .current-conditions,
    .map-legend-temps {
        flex: 1;
        min-width: 200px;
    }
}

@media (max-width: 600px) {
    .spain-weather-map {
        padding: 1rem;
    }

    .map-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .current-conditions {
        grid-template-columns: 1fr;
    }
}

/* Canvas charts placeholder */
canvas {
    width: 100% !important;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
}

/* Scrollbar styling */
.alerts-list::-webkit-scrollbar,
.recommendations-list::-webkit-scrollbar {
    width: 6px;
}

.alerts-list::-webkit-scrollbar-track,
.recommendations-list::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

.alerts-list::-webkit-scrollbar-thumb,
.recommendations-list::-webkit-scrollbar-thumb {
    background: #475569;
    border-radius: 3px;
}

.alerts-list::-webkit-scrollbar-thumb:hover,
.recommendations-list::-webkit-scrollbar-thumb:hover {
    background: #64748b;
}
