﻿/* ===========================
   CANTEEN CONFIG — headers jours/services en primary + panneau classes toujours visible
   =========================== */

/* ---- Layout principal ---- */
.canteen-config-container {
    display: flex;
    gap: 1.25rem;
    padding: 1rem;
}
/* plus de .is-view-mode */

/* =========================================
   PANEL CLASSES (toujours affiché)
   ========================================= */
.cc-classroom-panel {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 2px solid var(--primary-color);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 10px 24px rgba(0,0,0,.06);
}

.cc-classroom-panel__header {
    background: var(--primary-color);
    color: #fff;
    padding: .65rem .8rem;
    display: flex;
    flex-direction: column;
    gap: .15rem;
}

.cc-classroom-panel__title {
    font-weight: 800;
    font-size: .95rem;
    letter-spacing: .2px;
}

.cc-classroom-panel__hint {
    opacity: .92;
    font-size: .78rem;
}

.cc-classroom-panel__body {
    padding: .65rem .65rem .8rem .65rem;
    background: linear-gradient(180deg,#ffffff 0%,rgba(var(--primary-color-rgb),.035) 100%);
}

.cc-classroom-list {
    display: flex;
    flex-direction: column;
    gap: .4rem;
    overflow: auto;
    max-height: calc(100vh - 220px);
}

.cc-classroom-pill {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .6rem;
    background: rgba(var(--primary-color-rgb), .05);
    border: 1.5px solid var(--primary-color);
    color: var(--primary-color);
    padding: .35rem .55rem;
    border-radius: 8px;
    font-size: .92rem;
    font-weight: 700;
    cursor: grab;
    transition: transform .08s ease, background-color .15s ease, border-color .15s ease;
}

    .cc-classroom-pill:hover {
        background: rgba(var(--primary-color-rgb), .12);
        transform: translateY(-1px);
    }

    .cc-classroom-pill.is-full {
        opacity: .55;
        cursor: not-allowed;
        pointer-events: none;
        position: relative;
        background: #f8fafc;
        border-style: dashed;
    }

.cc-classroom-pill__name {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.cc-classroom-pill__meta {
    display: flex;
    align-items: center;
    gap: .35rem;
}

.cc-badge {
    display: inline-block;
    font-weight: 800;
    font-size: .75rem;
    background: #fff;
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
    padding: .05rem .45rem;
    border-radius: 999px;
}

.cc-grip {
    font-size: 1rem;
    color: var(--secondary-color);
}

/* =========================================
   CARTE AJOUT SERVICE
   ========================================= */
.cc-add-card {
    border: 1px solid rgba(0,0,0,.08);
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 8px 24px rgba(0,0,0,.06);
    overflow: hidden;
    width: fit-content;
    max-width: 100%;
}
    .cc-add-card.is-hidden {
        visibility: hidden; /* garde l'espace */
        pointer-events: none; /* évite clics / tab focus */
    }

    .cc-add-card.is-visible {
        visibility: visible;
    }

.cc-add-card-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: .5rem;
    padding: .75rem .85rem;
    background: linear-gradient(0deg, rgba(var(--primary-color-rgb), .12), rgba(var(--primary-color-rgb), .06));
    border-bottom: 2px solid var(--primary-color);
}

.cc-add-card-title {
    font-weight: 800;
    letter-spacing: .2px;
    display: flex;
    align-items: center;
    color: var(--primary-color);
}

.cc-add-card-help {
    font-size: .9rem;
    color: #334155;
    opacity: .85;
}

.cc-add-card-body {
    padding: .75rem .85rem .9rem .85rem;
    display: grid;
    gap: .6rem;
}

/* time fields — FLEX + centré */
.cc-time-fields {
    display: flex;
    align-items: flex-end;
    gap: .65rem;
    flex-wrap: wrap;
    text-align: center;
}

.cc-field label {
    display: block;
    margin-bottom: .2rem;
    font-weight: 800;
    font-size: .88rem;
    color: #0f172a;
    text-align: center;
}

.cc-field .form-control {
    width: 130px;
    min-width: 120px;
    max-width: 160px;
    border: 1.5px solid var(--primary-color);
    border-radius: 10px;
    background: #fff;
    padding: .45rem .55rem;
    font-size: .95rem;
    color: #0f172a;
    -webkit-text-fill-color: #0f172a;
    caret-color: var(--primary-color);
    box-shadow: inset 0 1px 0 rgba(0,0,0,.03);
}

    .cc-field .form-control:focus {
        outline: none;
        border-color: var(--primary-color);
        box-shadow: 0 0 0 4px rgba(var(--primary-color-rgb), .18);
    }

.cc-sep {
    align-self: center;
    color: #334155;
    font-weight: 800;
    margin: 0 .25rem;
    opacity: .9;
}

.cc-add-btn {
    white-space: nowrap;
    border: 0;
    border-radius: 10px;
    background: var(--secondary-color);
    color: #fff;
    padding: .55rem .9rem;
    font-weight: 900;
    letter-spacing: .2px;
    cursor: pointer;
    box-shadow: 0 3px 12px rgba(0,0,0,.06);
    transition: transform .06s ease, filter .15s ease, opacity .15s ease;
    align-self: end;
}

    .cc-add-btn:hover {
        filter: brightness(1.06);
        transform: translateY(-1px);
    }

    .cc-add-btn[disabled] {
        opacity: .55;
        cursor: not-allowed;
    }

.cc-presets {
    display: flex;
    flex-wrap: wrap;
    gap: .45rem .45rem;
    align-items: center;
}

.cc-preset-label {
    font-weight: 800;
    color: #334155;
    margin-right: .2rem;
}

.cc-chip {
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
    background: #fff;
    border-radius: 999px;
    padding: .32rem .6rem;
    font-weight: 800;
    font-size: .88rem;
    cursor: pointer;
    transition: background .12s ease, transform .06s ease, color .12s ease;
}

    .cc-chip:hover {
        background: var(--primary-color);
        color: #fff;
        transform: translateY(-1px);
    }

.cc-error {
    margin-top: .1rem;
    color: #991b1b;
    font-weight: 800;
    font-size: .9rem;
}

/* =========================================
   TABLE — headers jours + services sur primary
   ========================================= */
.canteen-config-table {
    width: 100%;
    table-layout: fixed;
    border-collapse: separate;
    border-spacing: 0;
    background: #fff;
    box-shadow: 0 10px 24px rgba(0, 0, 0, .06);
    border: 2px solid var(--primary-color);
    border-radius: 12px;
}

    /* header générique */
    .canteen-config-table thead th {
        position: sticky;
        top: 0;
        z-index: 3;
        background: linear-gradient(0deg, #ffffff, rgba(var(--primary-color-rgb), .08));
        text-transform: uppercase;
        letter-spacing: .3px;
        font-weight: 900;
        padding: 14px 16px;
        min-height: 54px;
        border-bottom: 2px solid var(--primary-color);
        color: #0f172a;
        text-align: center;
    }

.th-stack {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center; /* <-- centre dans la hauteur totale */
    min-height: 64px; /* <-- fixe une hauteur stable (ajuste si besoin) */
    gap: .15rem;
    width: 100%;
}

/* entêtes “jours” et “services” identiques, fond primary + texte blanc */
.th-day {
    background: var(--primary-color) !important;
    color: #fff !important;
    border-bottom: 2px solid var(--primary-color) !important;
}

    .th-day .th-day-name {
        color: #fff;
        font-weight: 900;
    }

    .th-day .canteen-day-sub {
        color: #fff;
        opacity: .95;
    }

    .th-day .canteen-day-counter {
        background: rgba(255,255,255,.15);
        color: #fff;
        border-color: rgba(255,255,255,.35);
    }

    .th-day .missing-badge {
        background: #fff;
        color: var(--primary-color);
        border-color: transparent;
    }

        .th-day .missing-badge.all-set {
            background: #ecfdf5;
            color: #065f46;
            border-color: #a7f3d0;
        }

        .th-day .missing-badge.has-missing {
            background: #fff5f5;
            color: #991b1b;
            border-color: #fecaca;
        }

/* sticky service column */
.canteen-config-table .canteen-service-col {
    position: sticky;
    left: 0;
    z-index: 2;
    background: #fff;
    border-right: 2px solid var(--primary-color);
    box-shadow: 6px 0 14px -10px rgba(0,0,0,.18);
}

/* cells */
.canteen-config-table th, .canteen-config-table td {
    background: #fff;
    padding: 12px 16px;
    border-right: 1px solid rgba(0,0,0,.06);
    border-bottom: 1px solid rgba(0,0,0,.06);
    vertical-align: middle;
    text-align: center;
    overflow: hidden;
}

/* zebra + hover bleuté */
.canteen-config-table tbody tr:nth-child(odd) td {
    background: rgba(var(--primary-color-rgb), .02);
}

.canteen-config-table tbody tr:nth-child(even) td {
    background: #fff;
}

.canteen-config-table tbody tr:hover td {
    background: rgba(var(--primary-color-rgb), .07);
    transition: background-color .12s ease;
}

    .canteen-config-table tbody tr:hover td:first-child {
        box-shadow: inset 4px 0 0 var(--primary-color);
    }

/* service cell content */
.canteen-service-label {
    text-align: left;
    color: #0f172a;
    white-space: nowrap;
}

.service-main {
    display: inline-flex;
    align-items: center;
    gap: .4rem; /* espace entre le rond, le chip et le bouton */
}

.service-chip {
    display: inline-flex;
    align-items: center;
    background: rgba(var(--primary-color-rgb), .10);
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
    padding: .18rem .55rem;
    border-radius: 999px;
    font-weight: 800;
    font-size: .95rem;
    line-height: 1.2;
}

.service-index-badge {
    width: 40px;
    height: 40px;
    border-radius: 999px;
    background: var(--secondary-color);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05rem;
    font-weight: 900;
    flex-shrink: 0;
    box-shadow: 0 3px 10px rgba(0,0,0,.12);
}


.service-hours {
    opacity: .95;
}

/* counters (hors entête jours) */
.canteen-day-sub {
    font-size: .75rem;
    font-weight: 700;
    color: #334155;
}

.canteen-day-counter {
    display: inline-block;
    margin-top: .1rem;
    font-size: .75rem;
    font-weight: 900;
    padding: .12rem .5rem;
    border-radius: 999px;
    border: 1px solid rgba(0,0,0,.06);
    background: #f1f5f9;
    color: #0f172a;
}

/* Missing indicator + pop */
.day-missing {
    position: relative;
    margin-top: .2rem;
}

.missing-badge {
    border: 1px solid var(--primary-color);
    background: #fff;
    font-weight: 900;
    font-size: .73rem;
    padding: .16rem .48rem;
    border-radius: 999px;
    cursor: default;
    color: var(--primary-color);
}

.missing-pop {
    position: absolute;
    top: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    min-width: 240px;
    max-width: 360px;
    max-height: 280px;
    overflow: auto;
    background: #fff;
    border: 2px solid var(--primary-color);
    border-radius: 12px;
    box-shadow: 0 16px 32px rgba(0,0,0,.16);
    padding: .65rem;
    display: none;
    z-index: 10;
}

.day-missing:hover .missing-pop, .day-missing:focus-within .missing-pop {
    display: block;
}

.missing-pop-title {
    font-weight: 900;
    font-size: .9rem;
    margin-bottom: .35rem;
    color: var(--primary-color);
}

.missing-pop-list {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem .45rem;
}

.missing-pop-foot {
    margin-top: .35rem;
    font-size: .8rem;
    color: #334155;
}

/* pills (table + pop) */
.canteen-config-pill {
    display: flex;
    align-items: center;
    gap: .5rem;
    background: rgba(var(--primary-color-rgb), .06);
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
    padding: .32rem .55rem;
    min-height: 32px;
    border-radius: 10px;
    font-size: 1.3rem;
    font-weight: 800;
    cursor: grab;
    transition: transform .08s ease, background-color .15s ease, border-color .15s ease;
    box-shadow: 0 3px 12px rgba(0,0,0,.04);
    max-width: 100%;
    width: auto;
    box-sizing: border-box;
    justify-content: center;
    overflow: hidden;
}

    .canteen-config-pill:hover {
        transform: translateY(-1px);
        background: rgba(var(--primary-color-rgb), .12);
    }

.canteen-config-delete-btn, .canteen-config-remove-button {
    border: 0;
    background: transparent;
    cursor: pointer;
    color: var(--important-color);
    font-size: 1.05rem;
    padding: 0 .2rem;
    border-radius: 8px;
    line-height: 1;
}

    .canteen-config-delete-btn:hover, .canteen-config-remove-button:hover {
        background: rgba(239,68,68,.08);
    }

.missing-pill {
    min-height: 28px;
    padding: .22rem .5rem;
    font-size: .85rem;
}

/* drop cells */
.canteen-drop-cell {
    position: relative;
    min-height: 92px;
    background: #fff;
    transition: background-color .12s ease, box-shadow .12s ease, outline-color .12s ease, transform .06s ease;
}

    .canteen-drop-cell.editable {
        outline: 3px dashed rgba(var(--primary-color-rgb), .35);
        outline-offset: -6px;
        background: linear-gradient(0deg,#fff,rgba(var(--primary-color-rgb),.03));
    }

        .canteen-drop-cell.editable.drag-over {
            background: #ffffff;
            box-shadow: inset 0 0 0 3px var(--primary-color);
            transform: translateY(0);
        }

.cell-pill-stack {
    display: flex;
    flex-direction: column; /* empile verticalement */
    gap: .35rem; /* espace vertical entre chaque pill */
    justify-content: flex-start;
    align-items: center;
    width: 100%;
}

.canteen-config-pill-name {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.canteen-drop-cell.cell-empty::before {
    content: "Déposer une classe";
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #334155;
    font-size: .9rem;
    font-weight: 800;
    opacity: .85;
    pointer-events: none;
}

/* Anim + barre saving */
@keyframes ccPulse {
    0% {
        transform: scale(0.98);
        box-shadow: 0 0 0 0 rgba(var(--primary-color-rgb),.28);
    }

    70% {
        transform: scale(1);
        box-shadow: 0 0 0 10px rgba(var(--primary-color-rgb),0);
    }

    100% {
        transform: scale(1);
        box-shadow: none;
    }
}

.added-once {
    animation: ccPulse .5s ease-out;
}

.canteen-config-table-wrapper {
    position: relative;
    flex: 1;
    overflow: auto;
    border-radius: 12px;
    scrollbar-gutter: stable;
}

.canteen-config-table-wrapper .canteen-config-table {
    min-width: 1100px;
}

    .canteen-config-table-wrapper.is-saving::after {
        content: "";
        position: sticky;
        top: 0;
        left: 0;
        right: 0;
        height: 3px;
        z-index: 5;
        display: block;
        background: linear-gradient(90deg, rgba(var(--primary-color-rgb),0) 0%, rgba(var(--primary-color-rgb),.95) 25%, rgba(var(--primary-color-rgb),.6) 50%, rgba(var(--primary-color-rgb),.95) 75%, rgba(var(--primary-color-rgb),0) 100%);
        animation: ccSaving 1.15s linear infinite;
    }

/* Assure une hauteur stable dans l'entête (titre + slot) */
.canteen-config-table thead th.th-day .th-stack {
    display: grid;
    align-items: center;
    justify-items: center;
    row-gap: .2rem;
    min-height: 64px; /* ajuste si besoin selon ton padding */
}

.day-missing-slot {
    height: 22px; /* hauteur réservée sous le titre */
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}

@keyframes ccSaving {
    0% {
        background-position: 0 0;
        background-size: 200% 100%;
    }

    100% {
        background-position: 200% 0;
        background-size: 200% 100%;
    }
}

/* coins arrondis fin de table */
.canteen-config-table tbody tr:last-child td:first-child {
    border-bottom-left-radius: 12px;
}

.canteen-config-table tbody tr:last-child td:last-child {
    border-bottom-right-radius: 12px;
}

/* Responsive */
@media (max-width:1280px) {
    .cc-classroom-panel {
    }

    .canteen-config-table th, .canteen-config-table td {
        min-width: 120px;
    }
}

@media (max-width:992px) {
    .canteen-config-container {
        flex-direction: column;
    }

    .cc-classroom-panel {
        width: 100%;
        min-width: 100%;
    }

    .cc-field .form-control {
        width: 120px;
        min-width: 110px;
    }

    .missing-pop {
        left: 0;
        transform: none;
        min-width: 200px;
        max-width: 90vw;
    }
}
