/* === ONIRIKA WEATHER SYSTEM - CSS EFFECTS CORRETTI === */
/* Sistema atmosferico emotivo per i Domini di Onirika - Versione corretta */

/* === VARIABILI WEATHER DINAMICHE === */
:root {
    /* Weather State Variables (controllate da JavaScript) */
    --weather-primary: transparent;
    --weather-secondary: transparent;
    --weather-intensity: 0.5;
    --weather-direction: 0deg;
    --weather-speed: 1;

    /* Particelle Weather */
    --weather-particle-color: rgba(255, 255, 255, 0.1);
    --weather-particle-size: 2px;
    --weather-particle-count: 20;

    /* Colori sistema */
    --primary-color: #667eea;
    --accent-color: #f093fb;
    --text-light: #e0e0e0;
    --text-dim: #bbb;
    --bg-dark: #1a1a1a;
    --bg-card: #2a2a2a;
    --bg-overlay: rgba(0, 0, 0, 0.7);
}

/* === FONT DEFINITIONS CORRETTE === */
.weather-domains-section,
.weather-domains-section * {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: var(--text-light);
}

/* === SEZIONE DOMINI METEO - INTEGRAZIONI CORRETTE === */

/* Domini Overview Section */
.weather-domains-section {
    margin: 2rem 0;
    padding: 1rem;
    background: var(--bg-overlay);
    border-radius: 12px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.domains-disclaimer {
    background: rgba(100, 149, 237, 0.15);
    padding: 1.2rem;
    border-radius: 8px;
    margin-bottom: 2rem;
    font-size: 0.95rem;
    line-height: 1.6;
    color: #e8f4fd;
}

.domains-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
    gap: 1.5rem;
    padding: 1rem 0;
}

/* === DOMAIN CARDS - CORREZIONI PRINCIPALI === */
.domain-weather-card {
    background: var(--bg-card);
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-left: 4px solid var(--primary-color, #667eea);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    /* CORREZIONE: Assicuriamo opacity stabile */
    opacity: 1;
    transform: translateZ(0);
    /* Force hardware acceleration */
}

.domain-weather-card.info-only {
    border-left-width: 6px;
}

.domain-weather-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    /* CORREZIONE: NO cambio di opacity al hover */
}

/* CORREZIONE CRITICA: Stati expanded */
.domain-weather-card.expanded,
.domain-weather-card.expanded:hover {
    /* RISOLTO: Manteniamo sempre opacity 1 */
    opacity: 1 !important;
    background: var(--bg-card) !important;
    transform: translateY(-2px);
}

.domain-header {
    padding: 1.5rem;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    transition: background 0.3s ease;
    /* CORREZIONE: Background stabile */
    background: transparent;
}

.domain-header:hover {
    background: rgba(255, 255, 255, 0.05);
}

/* CORREZIONE: Header expanded */
.domain-weather-card.expanded .domain-header {
    background: rgba(255, 255, 255, 0.08);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.domain-info {
    flex: 1;
    /* CORREZIONE: Migliore contenimento */
    min-width: 0;
    overflow: hidden;
}

.domain-name {
    margin: 0 0 1rem 0;
    color: #fff;
    font-size: 1.2rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    /* CORREZIONE: Gestione testo lungo */
    word-wrap: break-word;
    line-height: 1.3;
}

.monitoring-status {
    font-size: 0.75rem;
    background: rgba(76, 175, 80, 0.2);
    color: #4CAF50;
    padding: 0.2rem 0.5rem;
    border-radius: 10px;
    margin-left: 0.5rem;
    white-space: nowrap;
    border: 1px solid rgba(76, 175, 80, 0.3);
}

.domain-palette,
.domain-atmosphere,
.domain-intensity,
.domain-zones-count {
    margin: 0.8rem 0;
    color: var(--text-light);
    font-size: 0.9rem;
    line-height: 1.4;
    /* CORREZIONE: Migliore spacing */
    padding: 0.2rem 0;
}

/* === COLOR PREVIEW CORRETTA === */
.color-preview {
    display: flex;
    gap: 0.3rem;
    margin-top: 0.5rem;
    flex-wrap: wrap;
}

.color-sample {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.4);
    cursor: help;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.color-sample:hover {
    transform: scale(1.2);
    border-color: rgba(255, 255, 255, 0.8);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.5);
}

.condition-name {
    color: var(--primary-color, #667eea);
    font-weight: 600;
    text-shadow: 0 0 8px rgba(102, 126, 234, 0.3);
}

.condition-stability {
    margin-top: 0.5rem;
}

.stability-indicator {
    font-size: 0.8rem;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    display: inline-block;
    font-weight: 500;
}

.stability-indicator.stable {
    background: rgba(76, 175, 80, 0.2);
    color: #4CAF50;
    border: 1px solid rgba(76, 175, 80, 0.4);
}

.stability-indicator.neutral {
    background: rgba(255, 193, 7, 0.2);
    color: #FFC107;
    border: 1px solid rgba(255, 193, 7, 0.4);
}

.stability-indicator.unstable {
    background: rgba(244, 67, 54, 0.2);
    color: #F44336;
    border: 1px solid rgba(244, 67, 54, 0.4);
}

/* === DASHBOARD METEO CORRETTA === */
.meteo-dashboard {
    /* CORREZIONE: Layout migliore */
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.2rem;
    padding: 1.5rem;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 12px;
    margin: 1.5rem 0;
    border-top: 3px solid var(--primary-color);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.meteo-atmosfera,
.meteo-distorsione,
.meteo-cromatismo,
.meteo-intensita,
.meteo-influenze,
.meteo-previsioni {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    padding: 1.2rem;
    border-left: 4px solid transparent;
    transition: all 0.3s ease;
    /* CORREZIONE: Typography corretta */
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: var(--text-light);
    /* CORREZIONE: Contenimento del contenuto */
    overflow: hidden;
    word-wrap: break-word;
}

.meteo-atmosfera {
    border-left-color: #667eea;
}

.meteo-distorsione {
    border-left-color: #f093fb;
}

.meteo-cromatismo {
    border-left-color: #4facfe;
}

.meteo-intensita {
    border-left-color: #43e97b;
}

.meteo-influenze {
    border-left-color: #fa709a;
}

.meteo-previsioni {
    border-left-color: #ffecd2;
}

.meteo-atmosfera:hover,
.meteo-distorsione:hover,
.meteo-cromatismo:hover,
.meteo-intensita:hover,
.meteo-influenze:hover,
.meteo-previsioni:hover {
    background: rgba(255, 255, 255, 0.12);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* CORREZIONE: Titoli sezioni meteo */
.meteo-dashboard h4 {
    margin: 0 0 1rem 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.2);
    /* CORREZIONE: Miglior leggibilità */
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    letter-spacing: 0.02em;
}

/* CORREZIONE: Contenuto testi meteo */
.meteo-dashboard p,
.meteo-dashboard span,
.meteo-dashboard div {
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--text-light);
    margin-bottom: 0.5rem;
}

.meteo-dashboard strong {
    color: #fff;
    font-weight: 600;
}

.meteo-dashboard em {
    color: var(--text-dim);
    font-style: italic;
}

/* === COLOR PALETTE CORRETTA === */
.color-palette {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    align-items: center;
}

.color-palette .color-sample {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.4);
    cursor: help;
    transition: all 0.2s ease;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.color-palette .color-sample:hover {
    transform: scale(1.15);
    border-color: rgba(255, 255, 255, 0.9);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
}

/* === BARRA INTENSITÀ CORRETTA === */
.intensita-bar {
    width: 100%;
    height: 14px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

.intensita-fill {
    height: 100%;
    background: linear-gradient(90deg,
            rgba(67, 233, 123, 0.8) 0%,
            rgba(255, 193, 7, 0.8) 50%,
            rgba(244, 67, 54, 0.8) 100%);
    border-radius: 6px;
    transition: width 0.5s ease;
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.2);
}

/* === TOGGLE CONTROLS CORRETTI === */
.expand-toggle {
    background: transparent;
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: var(--text-light);
    padding: 0.6rem 0.8rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1.2rem;
    min-width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.expand-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.5);
    transform: scale(1.1);
}

.expand-toggle.expanded {
    background: rgba(102, 126, 234, 0.3);
    border-color: var(--primary-color);
    color: #fff;
    transform: rotate(180deg);
}

/* === STATI SPECIALI === */
.loading-state {
    opacity: 0.6;
    pointer-events: none;
    position: relative;
}

.loading-state::after {
    content: "⏳ Caricamento...";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.8);
    padding: 1rem 2rem;
    border-radius: 8px;
    color: #fff;
    font-size: 0.9rem;
}

.error-state {
    border-left-color: #f44336 !important;
    background: rgba(244, 67, 54, 0.1) !important;
}

.error-state .domain-name {
    color: #ff9999;
}

/* === RESPONSIVE DESIGN === */
@media (max-width: 1200px) {
    .domains-grid {
        grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    }

    .meteo-dashboard {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
        gap: 1rem;
        padding: 1rem;
    }
}

@media (max-width: 768px) {
    .weather-domains-section {
        margin: 1rem 0;
        padding: 0.5rem;
    }

    .domains-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .domain-header {
        padding: 1rem;
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }

    .expand-toggle {
        align-self: flex-end;
        margin-top: 0.5rem;
    }

    .meteo-dashboard {
        grid-template-columns: 1fr;
        padding: 1rem;
        gap: 0.8rem;
    }

    .color-palette {
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .domain-name {
        font-size: 1.1rem;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.3rem;
    }

    .monitoring-status {
        margin-left: 0;
        margin-top: 0.3rem;
    }

    .domains-disclaimer {
        padding: 1rem;
        font-size: 0.85rem;
    }

    .meteo-dashboard h4 {
        font-size: 1rem;
    }

    .meteo-dashboard p,
    .meteo-dashboard span,
    .meteo-dashboard div {
        font-size: 0.85rem;
    }
}

/* === PERFORMANCE OPTIMIZATIONS === */
.weather-domains-section * {
    will-change: auto;
}

.domain-weather-card {
    contain: layout style;
}

.meteo-dashboard {
    contain: layout;
}

/* === ACCESSIBILITY === */
@media (prefers-reduced-motion: reduce) {

    .domain-weather-card,
    .expand-toggle,
    .color-sample {
        transition: none;
    }

    .domain-weather-card:hover {
        transform: none;
    }

    .expand-toggle.expanded {
        transform: none;
    }
}

/* === DARK MODE ADJUSTMENTS === */
@media (prefers-color-scheme: light) {
    :root {
        --text-light: #333;
        --text-dim: #666;
        --bg-card: #f5f5f5;
        --bg-overlay: rgba(255, 255, 255, 0.9);
    }

    .domains-disclaimer {
        background: rgba(100, 149, 237, 0.1);
        color: #2c5282;
    }
}

/* === PRINT STYLES === */
@media print {
    .weather-domains-section {
        background: none !important;
        box-shadow: none !important;
        backdrop-filter: none !important;
    }

    .domain-weather-card {
        break-inside: avoid;
        background: #fff !important;
        color: #000 !important;
        box-shadow: 0 0 0 1px #ccc !important;
    }

    .expand-toggle {
        display: none;
    }

    .meteo-dashboard {
        display: block;
        background: none !important;
    }
}