/* =====================================================
   GRH – TABLEAUX SCOLAIRES (VERSION FINALE)
   Compatible Gutenberg / Front / Mobile
   ===================================================== */


/* =====================================================
   RESET / SÉCURITÉ GUTENBERG
   ===================================================== */

.wp-block-table,
.wp-block-table table,
.wp-block-group,
.wp-block-columns {
    max-width: 100% !important;
    width: 100% !important;
}


/* =====================================================
   LAYOUT PRINCIPAL (TABLE + MENU MATIÈRES)
   ===================================================== */

.grh-layout{
    display: flex !important;
    align-items: flex-start;
    gap: 20px;
    width: 100%;
}

/* Zone tableau */
.grh-layout > div:first-child{
    flex: 1 1 auto;
    min-width: 0;
}

/* Menu matières (à droite) */
.grh-menu{
    flex: 0 0 230px;
    width: 230px;
    border-left: 1px solid #ddd;
    padding-left: 10px;
}

.grh-menu a{
    display: block;
    padding: 6px;
    text-decoration: none;
}

.grh-menu a.active{
    background: #d9edf7;
    font-weight: bold;
}


/* =====================================================
   WRAPPER TABLE NOTES
   ===================================================== */

.grh-notes-wrapper{
    width: 100%;
    overflow-x: auto;
}


/* =====================================================
   TABLE NOTES – STRUCTURE
   ===================================================== */

.grh-notes-wrapper .grh-table{
    width: 100%;
    table-layout: fixed; /* 🔥 ESSENTIEL */
    border-collapse: collapse;
    font-size: 13px;
    border: 1px solid #ccc;
    background: transparent;
}

.grh-notes-wrapper .grh-table th,
.grh-notes-wrapper .grh-table td{
    border: 1px solid #ccc;
    padding: 6px;
    text-align: center;
    vertical-align: middle;
    box-sizing: border-box;
    background: transparent;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.grh-notes-wrapper .grh-table th{
    font-weight: 600;
}


/* =====================================================
   LARGEURS DES COLONNES (ORDRE RÉEL)
   ===================================================== */

/* # */
.grh-notes-wrapper .grh-table th:nth-child(1),
.grh-notes-wrapper .grh-table td:nth-child(1){
    width: 40px;
}

/* ID */
.grh-notes-wrapper .grh-table th:nth-child(2),
.grh-notes-wrapper .grh-table td:nth-child(2){
    width: 60px;
}

/* Élève */
.grh-notes-wrapper .grh-table th:nth-child(3),
.grh-notes-wrapper .grh-table td:nth-child(3){
    width: 200px;
    text-align: left;
}

/* Niveau */
.grh-notes-wrapper .grh-table th:nth-child(4),
.grh-notes-wrapper .grh-table td:nth-child(4){
    width: 90px;
}

/* Classe */
.grh-notes-wrapper .grh-table th:nth-child(5),
.grh-notes-wrapper .grh-table td:nth-child(5){
    width: 90px;
}

/* Examens */
.grh-notes-wrapper .grh-table th:nth-child(n+6):nth-child(-n+10),
.grh-notes-wrapper .grh-table td:nth-child(n+6):nth-child(-n+10){
    width: 80px;
}

/* Moyenne */
.grh-notes-wrapper .grh-table th:nth-child(11),
.grh-notes-wrapper .grh-table td:nth-child(11){
    width: 90px;
    font-weight: bold;
}


/* =====================================================
   INPUTS NOTES
   ===================================================== */

.grh-note{
    width: 100%;
    box-sizing: border-box;
    text-align: center;
    border: 1px solid #ccc;
    border-radius: 3px;
    background: transparent;
}

.grh-note.saving{ border-color: #0d6efd; }
.grh-note.saved{  border-color: #198754; }
.grh-note.error{  border-color: #dc3545; }

.grh-note.grh-disabled-input{
    background: #e9ecef !important;
    color: #6c757d !important;
    cursor: not-allowed;
}

/* Supprimer flèches number */
.grh-note::-webkit-outer-spin-button,
.grh-note::-webkit-inner-spin-button{
    -webkit-appearance: none;
    margin: 0;
}
.grh-note{
    -moz-appearance: textfield;
}


/* =====================================================
   LIGNE ACTIVE (CLAVIER)
   ===================================================== */

.grh-table tr.grh-row-active td{
    background: #FF8C00 !important;
}


/* =====================================================
   BOUTON VERROU
   ===================================================== */

#grh-toggle-lock{
    position: sticky;
    top: 20px;
    z-index: 10;
    margin-bottom: 14px;
}


/* =====================================================
   IMPRESSION
   ===================================================== */

@media print{
    body *{ visibility: hidden; }
    #grh-table, #grh-table *{ visibility: visible; }
    #grh-table{
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
    }
    .grh-menu,
    #grh-toggle-lock,
    #grh-search,
    #grh-lock-msg{
        display: none !important;
    }
}


/* =====================================================
   MOBILE
   ===================================================== */

@media (max-width: 768px){

    .grh-layout{
        flex-direction: column;
    }

    .grh-menu{
        width: 100%;
        border-left: none;
        border-top: 1px solid #ddd;
        display: flex;
        gap: 6px;
        overflow-x: auto;
    }

    .grh-menu a{
        white-space: nowrap;
        border: 1px solid #ccc;
        border-radius: 6px;
        padding: 6px 10px;
        background: #f8f9fa;
    }

    /* Table → cartes */
    .grh-table thead{ display: none; }

    .grh-table,
    .grh-table tbody,
    .grh-table tr,
    .grh-table td{
        display: block;
        width: 100%;
    }

    .grh-table tr{
        border: 1px solid #ccc;
        border-radius: 8px;
        padding: 10px;
        margin-bottom: 12px;
        background: #fff;
    }

    .grh-table td{
        border: none;
        padding: 6px 0;
        text-align: left;
    }

    .grh-table td::before{
        content: attr(data-label);
        font-weight: 600;
        font-size: 12px;
        color: #555;
        display: block;
        margin-bottom: 2px;
    }

    .grh-note{
        font-size: 16px;
        padding: 8px;
    }
}
/* Cadre externe du tableau */
.grh-notes-wrapper .grh-table{
    border: 1px solid #999;
}
