/* ===================================================================
   STYLES UNIFIÉS POUR TOUTES LES PAGES
   Container 1200px max, responsive, formulaires verticaux centrés
   =================================================================== */

/* ===== RESET ET BASE ===== */
* {
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
    background-color: #f7f9fc;
    margin: 0;
    padding: 0;
    font-size: 16px;
}

/* ===== NAVBAR ===== */
.navbar {
    text-align: center;
    background-color: #0047AB;
    padding: 12px 10px;
    color: white;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.navbar a {
    color: white;
    margin: 0 10px;
    text-decoration: none;
    font-size: 14px;
}

.navbar a:hover {
    text-decoration: underline;
}

/* ===== CONTAINERS PRINCIPAUX ===== */
/* Container standard pour toutes les pages */
.container,
.admin-container,
.correction-container,
.ean-container {
    max-width: 1200px;
    width: 100%;
    margin: 20px auto;
    padding: 30px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

/* ===== TITRES ===== */
h1, h2, h3, h4, h5 {
    text-align: center;
    color: #333;
    margin-top: 0;
}

h1 {
    font-size: 28px;
    margin-bottom: 20px;
}

h2 {
    font-size: 24px;
    margin-bottom: 20px;
    border-bottom: 2px solid #0047AB;
    padding-bottom: 12px;
}

h3 {
    font-size: 20px;
    margin-bottom: 15px;
}

h4 {
    font-size: 18px;
    margin-bottom: 10px;
}

h5 {
    font-size: 12px;
    margin-bottom: 10px;
}



/* ===== FORMULAIRES - DISPOSITION VERTICALE ===== */
form {
    max-width: 600px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: stretch;
}

/* Labels - toujours alignés à gauche */
label {
    display: block;
    text-align: left;
    font-weight: 600;
    margin-bottom: 5px;
    margin-top: 15px;
    color: #333;
    font-size: 15px;
}

label:first-of-type {
    margin-top: 0;
}

/* Inputs, selects, textareas - pleine largeur */
input[type="text"],
input[type="password"],
input[type="date"],
input[type="number"],
input[type="email"],
select,
textarea {
    width: 100%;
    padding: 12px;
    margin: 0 0 10px 0;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 16px;
    font-family: Arial, sans-serif;
    transition: border-color 0.3s, box-shadow 0.3s;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: #0047AB;
    box-shadow: 0 0 0 3px rgba(0, 71, 171, 0.1);
}

textarea {
    resize: vertical;
    min-height: 100px;
}

/* ===== BOUTONS ===== */
button,
input[type="submit"],
.btn,
.btn-action {
    display: block;
    width: 100%;
    max-width: 400px;
    margin: 20px auto 10px auto;
    padding: 14px 24px;
    background-color: #0047AB;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
    text-align: center;
    text-decoration: none;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

button:hover,
input[type="submit"]:hover,
.btn:hover {
    background-color: #FF7F00;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

/* Boutons Administration - Couleur différenciée */
.btn-admin {
    background-color: #6c757d; /* Gris pour différencier */
}

.btn-admin:hover {
    background-color: #5a6268;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

/* Boutons spéciaux dans les tableaux */
.btn-edit,
.btn-delete,
.btn-save,
.btn-cancel,
.btn-activate,
.btn-view {
    display: inline-block;
    width: auto;
    min-width: 100px;
    max-width: none;
    margin: 5px;
    padding: 8px 16px;
    font-size: 14px;
}

.btn-edit {
    background-color: #0d6efd;
}

.btn-edit:hover {
    background-color: #0b5ed7;
}

.btn-delete {
    background-color: #dc3545;
}

.btn-delete:hover {
    background-color: #bb2d3b;
}

.btn-save {
    background-color: #28a745;
}

.btn-save:hover {
    background-color: #218838;
}

.btn-cancel {
    background-color: #6c757d;
}

.btn-cancel:hover {
    background-color: #5a6268;
}

.btn-activate {
    background-color: #28a745;
}

.btn-activate:hover {
    background-color: #218838;
}

.btn-view {
    background-color: #95a5a6;
}

.btn-view:hover {
    background-color: #7f8c8d;
}

/* Wrapper pour centrer plusieurs boutons */
.button-wrapper,
.button-group {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin: 20px 0;
}

/* ===== SECTIONS ET CARDS ===== */
.admin-section {
    background: #f8f9fa;
    padding: 25px;
    border-radius: 8px;
    margin-bottom: 30px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.admin-section h3 {
    margin-top: 0;
    color: #333;
    border-bottom: 2px solid #0047AB;
    padding-bottom: 12px;
    font-size: 20px;
    font-weight: 600;
    text-align: center;
}

/* ===== GRILLES DE FORMULAIRES ADMIN ===== */
.admin-form-grid,
.form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
    margin-bottom: 15px;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.admin-form-group,
.form-group {
    display: flex;
    flex-direction: column;
}

.admin-form-group label,
.form-group label {
    font-weight: bold;
    margin-bottom: 5px;
    color: #555;
    text-align: left;
}

.admin-form-group input,
.admin-form-group select,
.admin-form-group textarea,
.form-group input,
.form-group select,
.form-group textarea {
    padding: 10px;
    margin: 0;
    width: 100%;
    box-sizing: border-box;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

/* ===== TABLEAUX ===== */
.admin-table-container,
.history-table-container,
.table-container {
    overflow-x: auto;
    margin: 20px 0;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    background: white;
}

.admin-table,
.history-table,
.calc-table,
.results-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

.admin-table th,
.history-table th,
.calc-table th,
.results-table th {
    background-color: #0047AB;
    color: white;
    padding: 12px;
    text-align: center;
    font-weight: bold;
    vertical-align: middle;
}

.admin-table td,
.history-table td,
.calc-table td,
.results-table td {
    padding: 12px;
    border-bottom: 1px solid #ddd;
    text-align: center;
    vertical-align: middle;
}

.admin-table tr:hover,
.history-table tr:hover,
.results-table tr:hover {
    background-color: #f5f5f5;
}

.admin-table tbody tr:last-child td {
    border-bottom: none;
}

/* ===== AFFICHAGE DES DONNÉES - TABLEAUX SPÉCIFIQUES ===== */
.energy-section {
    margin: 30px 0;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid #0047AB;
}

.energy-section h3 {
    margin-top: 0;
    color: #0047AB;
    font-size: 22px;
    margin-bottom: 20px;
    text-align: center;
}

.data-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
    padding: 15px;
    background: white;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.data-summary-item {
    text-align: center;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 6px;
    border-left: 3px solid #0047AB;
}

.data-summary-item .label {
    font-size: 12px;
    color: #666;
    text-transform: uppercase;
    margin-bottom: 5px;
}

.data-summary-item .value {
    font-size: 24px;
    font-weight: bold;
    color: #0047AB;
}

.data-summary-item .unit {
    font-size: 14px;
    color: #999;
}

/* Tableau de données mensuelles */
.monthly-data-table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
    background: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    border-radius: 8px;
    overflow: hidden;
}

.monthly-data-table thead {
    background: linear-gradient(135deg, #0047AB 0%, #0056c9 100%);
    color: white;
}

.monthly-data-table th {
    padding: 15px 10px;
    text-align: center;
    font-weight: 600;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.monthly-data-table td {
    padding: 12px 10px;
    text-align: center;
    border-bottom: 1px solid #e9ecef;
    font-size: 14px;
}

.monthly-data-table tbody tr:hover {
    background-color: #f8f9fa;
}

.monthly-data-table tbody tr:last-child td {
    border-bottom: none;
}

/* Colonnes spécifiques du tableau */
.monthly-data-table th:first-child,
.monthly-data-table td:first-child {
    text-align: left;
    padding-left: 20px;
    font-weight: 600;
}

.monthly-data-table .consumption-col {
    background-color: #fff3e0;
    font-weight: 600;
}

.monthly-data-table .cost-col {
    background-color: #e8f5e9;
    font-weight: 600;
}

.monthly-data-table .theo-col {
    background-color: #e3f2fd;
    font-weight: 600;
}

.monthly-data-table .nb-releves-col {
    font-size: 13px;
    color: #666;
}

/* ===== GRAPHIQUES ===== */
.chart-container {
    margin: 30px 0;
    padding: 20px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    min-height: 400px;
    position: relative;
}

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

.chart-title {
    text-align: center;
    margin-bottom: 20px;
    color: #333;
    font-size: 18px;
    font-weight: 600;
}

/* ===== MESSAGES NO DATA ===== */
.no-data {
    text-align: center;
    padding: 60px 20px;
    background: #f8f9fa;
    border-radius: 8px;
    margin: 30px 0;
}

.no-data h3 {
    color: #0047AB;
    margin-bottom: 15px;
    font-size: 24px;
}

.no-data p {
    color: #666;
    font-size: 16px;
    margin: 10px 0;
}

.no-data small {
    color: #999;
    font-size: 13px;
}

/* ===== MESSAGES ===== */
.success-message,
.error-message,
.warning-message,
.info-box,
.warning-box,
.danger-box {
    padding: 15px;
    border-radius: 4px;
    margin: 20px auto;
    max-width: 600px;
    text-align: center;
}

.success-message {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
    border-left: 4px solid #28a745;
}

.error-message {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    border-left: 4px solid #dc3545;
}

.warning-message,
.warning-box {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
    border-left: 4px solid #FF7F00;
}

.info-box {
    background-color: #e3f2fd;
    border-left: 4px solid #0047AB;
    color: #1565C0;
}

.danger-box {
    background-color: #f8d7da;
    border-left: 4px solid #e74c3c;
    color: #721c24;
}

/* ===== BADGES DE STATUT ===== */
.status-badge {
    display: inline-block;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
}

.status-active {
    background-color: #28a745;
    color: white;
}

.status-inactive {
    background-color: #dc3545;
    color: white;
}

.status-scheduled {
    background-color: #fd7e14;
    color: white;
}

.status-expired {
    background-color: #6c757d;
    color: white;
}

.status-pending {
    background-color: #f39c12;
    color: white;
}

/* ===== CHAMPS AUTOMATIQUES ===== */
.automatic-field-container {
    position: relative;
}

#compteur, 
#ean,
.automatic-field-container input[readonly] {
    background-color: #f0f0f0 !important;
    color: #666 !important;
    cursor: not-allowed !important;
    border: 1px solid #ccc !important;
}

#compteur:focus, 
#ean:focus,
.automatic-field-container input[readonly]:focus {
    outline: none !important;
    box-shadow: none !important;
    background-color: #f0f0f0 !important;
}

.automatic-field-container::after {
    content: "🔒";
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
    color: #999;
    pointer-events: none;
}

/* ===== HEURES PLEINES/CREUSES ===== */
.hp-hc-container {
    display: none;
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid #3498db;
    margin: 15px 0;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.hp-hc-container.active {
    display: block;
}

.hp-hc-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
    margin-top: 10px;
}

.hp-hc-field label {
    display: block;
    font-weight: bold;
    margin-bottom: 5px;
    color: #2c3e50;
}

.hp-hc-field input {
    width: 100%;
    padding: 8px;
    border: 2px solid #bdc3c7;
    border-radius: 4px;
    font-size: 14px;
    box-sizing: border-box;
}

.hp-hc-info {
    background: #e3f2fd;
    padding: 10px;
    border-radius: 5px;
    font-size: 0.9em;
    color: #1976d2;
    margin-bottom: 10px;
}

/* ===== RESPONSIVE - TABLETTES (768px) ===== */
@media (max-width: 768px) {
    .container,
    .admin-container,
    .correction-container,
    .ean-container {
        margin: 10px;
        padding: 20px;
        border-radius: 8px;
    }

    h1 {
        font-size: 22px;
    }

    h2 {
        font-size: 20px;
    }

    h3 {
        font-size: 18px;
    }

    /* Formulaires */
    form {
        max-width: 100%;
    }

    input[type="text"],
    input[type="password"],
    input[type="date"],
    input[type="number"],
    input[type="email"],
    select,
    textarea {
        font-size: 16px;
        padding: 12px;
    }

    /* Boutons */
	 /*
    button,
    input[type="submit"],
    .btn {
        width: 100%;
        max-width: 100%;
        padding: 14px 20px;
        font-size: 16px;
        margin: 10px 0;
    }
*/

    /* Boutons d'action dans tableaux */
    .btn-edit,
    .btn-delete,
    .btn-save,
    .btn-cancel,
    .btn-activate,
    .btn-view {
        display: block;
        width: 90%;
        max-width: 200px;
        margin: 5px auto;
    }

    /* Grilles */
    .admin-form-grid,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .hp-hc-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    /* Tableaux */
    .admin-table,
    .history-table,
    .results-table,
    .monthly-data-table {
        font-size: 12px;
    }

    .admin-table th,
    .admin-table td,
    .history-table th,
    .history-table td,
    .results-table th,
    .results-table td,
    .monthly-data-table th,
    .monthly-data-table td {
        padding: 8px 4px;
        font-size: 12px;
    }

    /* Navbar */
    .navbar {
        padding: 10px;
        font-size: 13px;
    }

    .navbar a {
        margin: 0 5px;
        font-size: 13px;
    }

    /* Graphiques */
    .chart-container {
        padding: 15px;
        min-height: 300px;
    }

    .chart-wrapper {
        height: 300px;
    }

    /* Data summary */
    .data-summary {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    /* Energy section */
    .energy-section {
        padding: 15px;
        margin: 20px 0;
    }
}

/* ===== RESPONSIVE - MOBILES (480px) ===== */
@media (max-width: 480px) {
    .container,
    .admin-container,
    .correction-container,
    .ean-container {
        margin: 5px;
        padding: 15px;
        border-radius: 6px;
    }

    h1 {
        font-size: 20px;
        margin-bottom: 15px;
    }

    h2 {
        font-size: 18px;
        margin-bottom: 15px;
    }

    h3 {
        font-size: 16px;
        margin-bottom: 10px;
    }

    /* Formulaires plus compacts */
    label {
        font-size: 14px;
        margin-top: 10px;
    }

    input[type="text"],
    input[type="password"],
    input[type="date"],
    input[type="number"],
    input[type="email"],
    select,
    textarea {
        font-size: 16px;
        padding: 12px 10px;
    }


    /* Boutons */
/*
    button,
    input[type="submit"],
    
	 .btn {
        width: 100%;
        max-width: 100%;
        padding: 14px 16px;
        font-size: 15px;
        margin: 8px 0;
    }
*/
    /* Sections admin */
    .admin-section {
        padding: 15px;
        margin-bottom: 15px;
    }

    /* Messages */
    .success-message,
    .error-message,
    .warning-message,
    .info-box,
    .warning-box {
        font-size: 14px;
        padding: 12px;
        margin: 15px 0;
    }

    /* Tableaux encore plus compacts */
    .admin-table,
    .history-table,
    .results-table,
    .monthly-data-table {
        font-size: 11px;
    }

    .admin-table th,
    .admin-table td,
    .history-table th,
    .history-table td,
    .results-table th,
    .results-table td,
    .monthly-data-table th,
    .monthly-data-table td {
        padding: 6px 3px;
        font-size: 11px;
    }

    .monthly-data-table th:first-child,
    .monthly-data-table td:first-child {
        padding-left: 8px;
    }

    /* HP/HC */
    .hp-hc-container {
        padding: 12px;
        margin: 10px 0;
    }

    .hp-hc-info {
        font-size: 0.8em;
        padding: 8px;
    }

    /* Indicateurs automatiques */
    .automatic-field-container::after {
        right: 5px;
        font-size: 10px;
    }

    /* Graphiques mobiles */
    .chart-container {
        padding: 10px;
        min-height: 250px;
        margin: 20px 0;
    }

    .chart-wrapper {
        height: 250px;
    }

    .chart-title {
        font-size: 16px;
        margin-bottom: 15px;
    }

    /* Data summary mobile */
    .data-summary {
        grid-template-columns: 1fr;
        gap: 10px;
        padding: 10px;
    }

    .data-summary-item {
        padding: 12px;
    }

    .data-summary-item .value {
        font-size: 20px;
    }

    /* Energy section mobile */
    .energy-section {
        padding: 12px;
        margin: 15px 0;
    }

    .energy-section h3 {
        font-size: 18px;
    }

    /* No data mobile */
    .no-data {
        padding: 40px 15px;
    }

    .no-data h3 {
        font-size: 20px;
    }

    .no-data p {
        font-size: 14px;
    }
}

/* ===== UTILITAIRES ===== */
.text-center {
    text-align: center !important;
}

.text-left {
    text-align: left !important;
}

.text-right {
    text-align: right !important;
}

.mt-10 {
    margin-top: 10px !important;
}

.mt-20 {
    margin-top: 20px !important;
}

.mb-10 {
    margin-bottom: 10px !important;
}

.mb-20 {
    margin-bottom: 20px !important;
}

/* Animation de fade-in */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.success-message,
.error-message,
.warning-message {
    animation: fadeIn 0.3s ease-in;
}
