/* =================================
   SCREENSAVER - ÉCRAN DE VEILLE
   ================================= */
/* Variables CSS pour cohérence avec le thème */
:root {
    --bg-color: #000000;
    --widget-bg: #1C1C1E;
    --text-color: #FFFFFF;
    --text-secondary: #AAAAAA;
    --border-color: #333333;
    --accent-orange: #FF8C00;
    --danger-red: #dc3545;
    --success-green: #28a745;
    --font-family: 'Inter', sans-serif;
    /* Couleurs spécifiques écran de veille */
    --electric-color: #ffd700;
    --water-color: #00bfff;
    --gas-color: #8e44ad; /* Violet */
    --co2-color: #ff4757;
    --temperature-color: #ff6348;
    --humidity-color: #1dd1a1;    
    /* Transitions */
    --transition-standard: 0.3s ease;
    --transition-slow: 0.6s ease;
}

/* =================================
   BASE STYLES
   ================================= */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: var(--bg-color);
    min-height: 100vh;
    overflow: hidden;
    color: var(--text-color);
    user-select: none;
}

/* Animation d'apparition */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideIn {
    from { transform: translateX(-100%); }
    to { transform: translateX(0); }
}

@keyframes chartAnimation {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* =================================
   LAYOUT PRINCIPAL - CSS GRID
   ================================= */

.screensaver-container {
    display: grid;
    grid-template-columns: 2fr 2fr 1.2fr;
    grid-template-rows: 1fr auto;
    gap: 30px;
    height: 100vh;
    padding: 30px;
    grid-template-areas: 
        "main-chart secondary-charts progress-bars"
        "status status status";
}

/* =================================
   BOUTONS DE CONTRÔLE
   ================================= */

.back-button {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 1000;
    transition: var(--transition-standard);
}

.fullscreen-button {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    transition: var(--transition-standard);
}

.btn-back, .btn-fullscreen {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    color: white;
    text-decoration: none;
    backdrop-filter: blur(10px);
    transition: var(--transition-standard);
    font-size: 14px;
    font-weight: 500;
}

.btn-back:hover, .btn-fullscreen:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
    color: white;
    text-decoration: none;
}

/* Masquer les boutons en plein écran */
:fullscreen .back-button,
:fullscreen .fullscreen-button {
    opacity: 0;
    pointer-events: none;
}

/* =================================
   DOUGHNUT CHARTS
   ================================= */

.main-chart-container {
    grid-area: main-chart;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.8s ease;
}

.secondary-charts-container {
    grid-area: secondary-charts;
    display: flex;
    flex-direction: column;
    gap: 20px;
    animation: fadeIn 0.8s ease 0.2s both;
}

.chart-card {
    background-color: var(--widget-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 32px;
    transition: var(--transition-standard);
    position: relative;
    overflow: hidden;
    height: 100%;
}

/* Styles pour le lien du graphique électrique afin de neutraliser les styles par défaut */
.clickable-chart {
    display: block; /* Assure que le lien prend toute la place de la carte */
    text-decoration: none; /* Supprime le soulignement */
    color: inherit; /* Fait hériter la couleur du texte (blanc) du parent */
}

.clickable-chart:hover,
.clickable-chart:active,
.clickable-chart:focus {
    text-decoration: none; /* Pas de soulignement au survol ou au clic */
    color: inherit; /* Maintient la couleur blanche du texte */
}

.chart-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}

/* Style pour rendre une carte cliquable */
.clickable-card-link {
    display: block;
    text-decoration: none;
    color: inherit;
    border-radius: 16px; /* Doit correspondre au border-radius de .progress-section */
    transition: var(--transition-standard);
}

.clickable-card-link:hover .progress-section {
    transform: translateY(-5px) translateX(5px);
    background: rgba(255, 255, 255, 0.2);
}

/* Tailles des charts */
.electric-chart {
    width: 100%;
    height: 100%;
    min-height: 500px;
}

.water-chart, .gas-chart {
    height: 100%;
    min-height: 350px;
}

.chart-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
    font-size: 20px;
    font-weight: 600;
}

.chart-header i {
    font-size: 28px;
}

.electric-chart .chart-header i { color: var(--electric-color); }
.water-chart .chart-header i { color: var(--water-color); }
.gas-chart .chart-header i { color: var(--gas-color); } /* Utilisation de la nouvelle variable */

.chart-wrapper {
    position: relative;
    height: calc(100% - 120px);
    margin-bottom: 20px;
    min-height: 250px;
}

.electric-chart .chart-wrapper {
    height: calc(100% - 140px);
    min-height: 350px;
}

/* Texte au centre des doughnut charts */
.chart-center-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    pointer-events: none;
}

.cumulative-value {
    font-size: 36px;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 6px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

/* Tailles améliorées pour la visibilité à distance */
.large-cumulative {
    font-size: 52px !important;
    font-weight: 800;
    text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.4);
}

.medium-cumulative {
    font-size: 40px !important;
    font-weight: 700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.cumulative-label {
    font-size: 16px;
    opacity: 0.8;
    font-weight: 500;
}

.footer-value-container {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.footer-label {
    font-size: 14px;
    opacity: 0.7;
    font-weight: 400;
    align-self: center; /* Pour mieux s'aligner avec la valeur */
}

.chart-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.current-value {
    font-size: 18px;
    font-weight: 600;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

/* Tailles améliorées pour les valeurs actuelles */
.large-current {
    font-size: 24px !important;
    font-weight: 700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.4);
}

.medium-current {
    font-size: 20px !important;
    font-weight: 650;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.3);
}

.chart-status {
    font-size: 20px;
    animation: pulse 2s infinite;
}

.chart-status.connected { color: var(--success-color); }
.chart-status.disconnected { color: var(--danger-color); }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* =================================
   PROGRESS BARS
   ================================= */

.progress-bars-container {
    grid-area: progress-bars;
    display: flex;
    flex-direction: column;
    gap: 20px;
    animation: fadeIn 0.8s ease 0.4s both;
    height: 100%;
    justify-content: space-around; /* Mieux espacer les 3 barres restantes */
}

.progress-section {
    background-color: var(--widget-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 28px;
    transition: var(--transition-standard);
    animation: slideIn 0.6s ease;
    flex: 1;
    min-height: 140px;
}

.progress-section:hover {
    transform: translateX(5px);
    background: rgba(255, 255, 255, 0.15);
}

.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.progress-title {
    font-size: 18px;
    font-weight: 500;
    opacity: 0.9;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
}

.progress-value {
    font-size: 26px;
    font-weight: 700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

/* Tailles améliorées pour les valeurs des progress bars */
.large-value {
    font-size: 34px !important;
    font-weight: 800;
    text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.4);
    line-height: 1.1;
}

/* Couleurs spécifiques pour les différents types de valeurs */
.temperature-value {
    color: #ff9f43;
}

.humidity-value {
    color: #54a0ff;
}

.progress-bar-wrapper {
    margin: 20px 0;
}

.progress-bar {
    width: 100%;
    height: 14px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 14px;
    overflow: hidden;
    position: relative;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.progress-fill {
    height: 100%;
    border-radius: 14px;
    transition: width var(--transition-slow);
    position: relative;
    background: linear-gradient(90deg, var(--primary-color), #00d2ff);
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.3);
}

/* Couleurs spécifiques pour les progress bars */
.cost-fill {
    background: linear-gradient(90deg, var(--accent-orange), #ffd700);
    box-shadow: 0 2px 8px rgba(255, 140, 0, 0.4);
}

.co2-fill {
    background: linear-gradient(90deg, var(--co2-color), #ff6b6b);
    box-shadow: 0 2px 8px rgba(255, 71, 87, 0.4);
}

.temperature-fill {
    background: linear-gradient(90deg, var(--temperature-color), #ff9ff3);
    box-shadow: 0 2px 8px rgba(255, 99, 72, 0.4);
}

.humidity-fill {
    background: linear-gradient(90deg, var(--humidity-color), #54a0ff);
    box-shadow: 0 2px 8px rgba(29, 209, 161, 0.4);
}

/* Animation de remplissage */
.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { left: -100%; }
    100% { left: 100%; }
}

.progress-footer {
    font-size: 14px;
    opacity: 0.9;
    font-weight: 500;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
}

/* Tailles améliorées pour les informations du footer */
.large-info {
    font-size: 18px !important;
    font-weight: 600;
    opacity: 1;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.cost-info {
    color: var(--warning-color);
}

.comparison-info {
    color: var(--info-color);
}

/* Valeurs importantes dans le footer */
.cost-amount {
    font-size: 1.3em;
    font-weight: 700;
    color: #ffb142;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.4);
}

.comparison-value {
    font-size: 1.2em;
    font-weight: 700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.4);
}

/* =================================
   STATUS BAR
   ================================= */

.status-container {
    grid-area: status;
    display: flex;
    justify-content: center;
    gap: 60px;
    padding: 20px;
    background-color: var(--widget-bg);
    border: 1px solid var(--border-color); 
    border-radius: 16px;
    animation: fadeIn 0.8s ease 0.6s both;
}

.status-item {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 18px;
    font-weight: 600;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

.status-item i {
    font-size: 20px;
    opacity: 0.9;
}

/* Styles pour les liens et boutons dans le status-container */
.status-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    color: white;
    text-decoration: none;
    backdrop-filter: blur(10px);
    transition: var(--transition-standard);
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
}

.status-button {
    background: none;
    border: 1px solid var(--glass-border);
}

.status-link:hover, .status-button:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
    color: white;
    text-decoration: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.status-link:active, .status-button:active {
    transform: translateY(0);
}

.status-link i {
    font-size: 16px;
    opacity: 1;
}

/* =================================
   OVERLAY DE CONFIGURATION
   ================================= */

.config-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition-standard);
}

.config-overlay.show {
    opacity: 1;
    visibility: visible;
}

.config-panel {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    backdrop-filter: blur(20px);
    padding: 32px;
    max-width: 500px;
    width: 90%;
    animation: chartAnimation 0.5s ease;
}

.config-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.config-header h3 {
    margin: 0;
    font-size: 24px;
    font-weight: 600;
}

.btn-close {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: var(--transition-standard);
}

.btn-close:hover {
    background: rgba(255, 255, 255, 0.1);
}

.config-body p {
    margin-bottom: 24px;
    line-height: 1.6;
    opacity: 0.9;
}

.config-actions {
    display: flex;
    gap: 16px;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition-standard);
    cursor: pointer;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-secondary {
    background: var(--glass-bg);
    color: white;
    border: 1px solid var(--glass-border);
}

.btn:hover {
    transform: translateY(-2px);
    text-decoration: none;
    color: white;
}

/* =================================
   RESPONSIVE DESIGN
   ================================= */

@media (max-width: 1200px) and (min-width: 769px) { body:not(.dev-mode) {
    .screensaver-container {
        grid-template-columns: 1fr 1fr 1fr;
        grid-template-rows: auto auto auto;
        grid-template-areas:
            "main-chart secondary-charts secondary-charts"
            "progress-bars progress-bars progress-bars"
            "status status status";
        gap: 10px;
        padding: 10px;
        align-content: start;
    }

    .secondary-charts-container {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
        flex-direction: row; 
    }

    .progress-bars-container {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
        align-content: center;
    }
    
    .chart-card {
        padding: 10px;
        display: flex;
        flex-direction: column;
    }

    .electric-chart,
    .water-chart,
    .gas-chart {
        min-height: 180px;
    }
    
    .chart-header {
        font-size: 15px;
        margin-bottom: 8px;
    }
    .chart-header i {
        font-size: 18px;
    }

    .chart-wrapper {
        flex-grow: 1;
        min-height: 100px;
        height: auto;
        margin-bottom: 5px;
    }

    .electric-chart .chart-wrapper {
        min-height: 100px;
    }

    .chart-footer {
        margin-top: auto;
        padding-top: 5px;
    }

    /* Font sizes */
    .large-cumulative { font-size: 54px !important; }
    .medium-cumulative { font-size: 54px !important; }
    .large-current { font-size: 15px !important; }
    .medium-current { font-size: 13px !important; }
    .cumulative-label { font-size: 16px; }
    
    .progress-section {
        padding: 10px;
    }
    
    .progress-title { font-size: 13px; }
    .large-value { font-size: 18px !important; }
    .progress-bar-wrapper { margin: 8px 0; }
    .large-info { font-size: 12px !important; }
    
    .status-container {
        padding: 5px 15px;
        gap: 30px;
        width: 100%;
        margin: 0;
        min-height: 45px;
        justify-content: center;
        align-items: center;
    }

    .status-item {
        font-size: 14px;
    }

    .status-item i {
        font-size: 16px;
    }
    
    .voice-item {
        gap: 10px !important;
    }

    .status-container .voice-chat-button {
        padding: 8px 12px;
        font-size: 0.9rem;
        min-width: 100px;
        min-height: 40px;
    }

    .status-container .stop-speech-button {
        padding: 8px 12px;
        font-size: 0.9rem;
        min-height: 40px;
    }
}}

@media (max-width: 768px) {
    .screensaver-container {
        grid-template-columns: 1fr;
        grid-template-areas: 
            "main-chart"
            "secondary-charts"
            "progress-bars"
            "status";
        padding: 15px;
        gap: 20px;
    }
    
    .secondary-charts-container {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 20px;
    }
    
    .progress-bars-container {
        display: flex;
        flex-direction: column;
    }
    
    .electric-chart {
        min-height: 400px;
    }
    
    .water-chart, .gas-chart {
        min-height: 280px;
    }
    
    .status-container {
        gap: 20px;
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .status-link {
        font-size: 14px;
        padding: 6px 12px;
    }
    
    /* Maintenir la lisibilité sur tablette */
    .large-value {
        font-size: 30px !important;
    }
    
    .large-cumulative {
        font-size: 46px !important;
    }
    
    .large-info {
        font-size: 16px !important;
    }
}

@media (max-width: 480px) {
    .screensaver-container {
        padding: 8px;
        gap: 12px;
    }
    
    .secondary-charts-container {
        grid-template-columns: 1fr;
    }
    
    .chart-card {
        padding: 16px;
    }
    
    .progress-section {
        padding: 20px;
        min-height: 130px;
    }
    
    .status-container {
        flex-direction: column;
        gap: 12px;
        text-align: center;
    }
    
    .status-link {
        font-size: 13px;
        padding: 8px 12px;
        justify-content: center;
    }
    
    .status-link span {
        display: none;
    }
    
    .status-link i {
        font-size: 18px;
        margin: 0;
    }
    
    /* Ajustements pour mobile tout en gardant la lisibilité */
    .large-value {
        font-size: 26px !important;
    }
    
    .large-cumulative {
        font-size: 38px !important;
    }
    
    .medium-cumulative {
        font-size: 32px !important;
    }
    
    .large-current {
        font-size: 20px !important;
    }
    
    .large-info {
        font-size: 15px !important;
    }
    
    .cost-amount {
        font-size: 1.2em;
    }
    
    .comparison-value {
        font-size: 1.1em;
    }
}

.voice-chat-button {
    padding: 8px 16px;
    font-size: 0.9rem;
    min-height: 40px;
}

.stop-speech-button {
    padding: 8px 12px;
    font-size: 0.9rem;
    min-height: 40px;
}

/* Styles pour le bouton vocal */
.voice-item {
    position: relative;
    display: flex;
    gap: 15px;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    max-width: 500px;
}

.voice-chat-button {
    background: transparent;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 15px;
    color: #ffffff;
    padding: 20px 50px;
    font-size: 1.1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    min-width: 300px;
    max-width: 400px;
    min-height: 60px;
    flex: 1;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.voice-chat-button:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.2);
}

.voice-chat-button:active,
.voice-chat-button.recording {
    background: rgba(220, 53, 69, 0.2);
    border-color: #dc3545;
    color: #ff6b6b;
    transform: scale(0.95);
    animation: pulse-recording 1.5s infinite;
}

@keyframes pulse-recording {
    0% { box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.7); }
    70% { box-shadow: 0 0 0 15px rgba(220, 53, 69, 0); }
    100% { box-shadow: 0 0 0 0 rgba(220, 53, 69, 0); }
}

.voice-chat-button i {
    font-size: 1.2rem;
}

/* Notification toast pour l'écran de veille */
.screensaver-notification {
    position: fixed;
    top: 30px;
    right: 30px;
    z-index: 9999;
    min-width: 300px;
    max-width: 500px;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 20px;
    border-radius: 10px;
    border-left: 4px solid #007bff;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    transform: translateX(100%);
    transition: transform 0.3s ease;
}

.screensaver-notification.show {
    transform: translateX(0);
}

.screensaver-notification.success {
    border-left-color: #28a745;
}

.screensaver-notification.error {
    border-left-color: #dc3545;
}

.screensaver-notification.warning {
    border-left-color: #ffc107;
}

.screensaver-notification.info {
    border-left-color: #17a2b8;
}

/* Agrandissement du bouton vocal */
.voice-chat-button-large {
    min-width: 250px;
    padding: 12px 24px;
    font-size: 1.1rem;
    font-weight: 600;
}

.voice-chat-button-large i {
    font-size: 1.3rem;
}