/* 
 * Styles pour la page de statistiques de l'application Order Prep
 * Version avec fixation agressive du problème de chevauchement
 */

.stats-container {
    font-family: 'Open Sans', sans-serif;
    padding: 15px;
    background-color: #f9f9f9;
    height: 100%;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    /* Ajout d'un padding-bottom important pour éviter le chevauchement */
    padding-bottom: calc(var(--order-prep-nav-total, 60px) + 60px) !important;
}

/* En-tête des statistiques */
.stats-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    width: 100%;
}

.stats-header-left {
    display: flex;
    flex-direction: column;
}

.stats-day-label {
    font-size: 16px;
    font-weight: 500;
    color: #333;
    margin: 0;
}

.stats-date {
    font-size: 14px;
    color: #666;
    margin: 2px 0 0 0;
}

.stats-logo {
    max-width: 100px;
    height: auto;
}

/* Bloc de statistiques */
.stats-block {
    background-color: #fff;
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 15px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    width: 100%;
    box-sizing: border-box;
}

.stats-block-title {
    font-size: 16px;
    font-weight: 500;
    color: #333;
    margin: 0 0 10px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.stats-period-label {
    color: var(--op-ink);
    font-size: 14px;
}

/* Lignes des statistiques */
.stats-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f0;
    width: 100%;
}

.stats-row:last-child {
    border-bottom: none;
}

.stats-label {
    font-size: 14px;
    color: #666;
    width: 50%;
}

.stats-value {
    font-size: 16px;
    font-weight: bold;
    color: #333;
    width: 50%;
    text-align: right;
}

/* Section sélecteur de date */
.stats-date-selector {
    display: flex;
    justify-content: space-between;
    margin-bottom: 15px;
    width: 100%;
    box-sizing: border-box;
}

.stats-date-field {
    width: 48%;
}

.stats-date-input {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
    color: #333;
    box-sizing: border-box;
}

/* Graphique des ventes - CORRECTION MAJEURE */
.stats-chart-container {
    background-color: #fff;
    border-radius: 10px;
    padding: 15px;
    /* Augmentation drastique de la marge en bas */
    margin-bottom: 120px; 
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    width: 100%;
    box-sizing: border-box;
    position: relative;
}

.stats-chart {
    width: 100%;
    /* Réduction de la hauteur du graphique */
    height: 250px;
    position: relative;
    /* Assurer que le contenu reste dans la boîte */
    overflow: hidden;
}

/* Correction spécifique pour le conteneur du graphique */
canvas#monthly-sales-chart {
    margin-bottom: 20px !important;
    max-height: 230px !important;
}

/* Force le conteneur principal à respecter l'espace pour la navigation */
.order-prep-container.stats-page {
    padding-bottom: calc(var(--order-prep-nav-total, 60px) + 60px) !important;
}

/* Augmenter la hauteur avec la navigation bottom */
.order-prep-full-page {
    padding-bottom: calc(var(--order-prep-nav-total, 60px) + 60px) !important;
}

/* Styles pour l'accordéon */
.stats-accordion {
    background-color: #fff;
    border-radius: 10px;
    margin-bottom: 15px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    overflow: hidden;
    width: 100%;
    box-sizing: border-box;
}

.stats-accordion-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 16px;
    font-weight: 500;
    color: #333;
    padding: 15px;
    cursor: pointer;
    transition: background-color 0.3s;
    width: 100%;
    box-sizing: border-box;
}

.stats-accordion-header:hover {
    background-color: #f9f9f9;
}

.stats-accordion-header.collapsed svg {
    transform: rotate(180deg);
}

.stats-accordion-content {
    display: none;
    padding: 0 15px;
    border-top: 1px solid #f0f0f0;
    width: 100%;
    box-sizing: border-box;
}

.stats-trend-up {
    color: var(--op-ink);
}

.stats-trend-down {
    color: #ff3d00; /* Rouge pour les tendances négatives */
}

.stats-daily-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #f0f0f0;
    width: 100%;
    box-sizing: border-box;
}

.stats-daily-row:last-child {
    border-bottom: none;
}

.stats-daily-date {
    width: 25%;
    font-size: 14px;
    color: #333;
}

.stats-daily-value {
    width: 35%;
    font-size: 14px;
    font-weight: bold;
    text-align: right;
}

.stats-daily-value.higher {
    color: #00c853; /* Vert pour les valeurs supérieures à la semaine précédente */
}

.stats-daily-value.lower {
    color: #ff3d00; /* Rouge pour les valeurs inférieures à la semaine précédente */
}

.stats-daily-count {
    width: 40%;
    font-size: 14px;
    color: #666;
    text-align: right;
}

/* Responsive */
@media (max-width: 480px) {
    .stats-container {
        padding: 10px;
        margin: 0;
        width: 100vw;
        max-width: 100%;
        /* Padding extrême pour mobile */
        padding-bottom: calc(var(--order-prep-nav-total, 60px) + 80px) !important;
    }
    
    .stats-day-label {
        font-size: 15px;
    }
    
    .stats-date {
        font-size: 13px;
    }
    
    .stats-logo {
        max-width: 70px;
    }
    
    .stats-value {
        font-size: 15px;
    }
    
    .stats-block {
        padding: 10px;
        width: 100%;
        margin-left: 0;
        margin-right: 0;
    }
    
    /* Modification pour que le tableau prenne toute la largeur */
    .stats-accordion {
        width: 100%;
        margin-left: 0;
        margin-right: 0;
    }
    
    .stats-accordion-header {
        padding: 12px 10px;
    }
    
    .stats-accordion-content {
        padding: 0 5px;
    }
    
    .stats-daily-row {
        width: 100%;
        display: flex;
        padding: 10px 5px;
        justify-content: space-between;
    }
    
    .stats-daily-date {
        width: 20%;
        font-size: 12px;
        padding-right: 5px;
    }
    
    .stats-daily-value {
        width: 38%;
        font-size: 12px;
        text-align: right;
        padding-right: 5px;
    }
    
    .stats-daily-count {
        width: 42%;
        font-size: 12px;
        text-align: right;
    }
    
    /* Ajustement du sélecteur de date sur mobile */
    .stats-date-selector {
        width: 100%;
    }
    
    .stats-date-input:focus {
    border-color: var(--op-ink);
    outline: none;
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.14);
}
    
    .stats-date-field {
        width: 48%;
    }
    
    .stats-date-input {
        font-size: 12px;
        padding: 8px 5px;
    }
    
    /* Correction encore plus agressive pour mobile */
    .stats-chart-container {
        margin-bottom: 30px !important;
        border-top: 3px solid var(--op-ink);
    }
    
    .stats-chart {
        height: 200px !important;
    }
    
    canvas#monthly-sales-chart {
        max-height: 180px !important;
    }
    
    /* Force de l'affichage complet */
    .order-prep-container.stats-page {
        padding-bottom: calc(var(--order-prep-nav-total, 60px) + 80px) !important;
    }
    
    .order-prep-full-page {
        padding-bottom: calc(var(--order-prep-nav-total, 60px) + 80px) !important;
    }
}