/* =============================================
   ADMIN — Layout général
   ============================================= */

body:has(.admin-layout) {
    padding-top: 0;
    background: var(--color-bg-admin);
}

.admin-layout {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    font-family: 'Helvetica Neue', Arial, sans-serif;
}

/* =============================================
   Topbar
   ============================================= */

.admin-topbar {
    font-family: 'Helvetica Neue', Arial, sans-serif;
    display: flex;
    align-items: center;
    background: var(--primary-color);
    height: 52px;
    padding: 0 32px;
    gap: 32px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.admin-topbar-brand {
    font-size: 13px;
    font-weight: 700;
    color: var(--color-teal);
    text-transform: uppercase;
    letter-spacing: 2px;
    white-space: nowrap;
}

.admin-topbar-nav {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 4px;
    flex: 1;
}

.admin-topbar-nav li a {
    display: block;
    padding: 0 16px;
    line-height: 52px;
    font-size: 14px;
    color: var(--color-gray-400);
    text-decoration: none;
    border-bottom: 3px solid transparent;
    transition: color 0.2s, border-color 0.2s;
}

.admin-topbar-nav li a:hover,
.admin-topbar-nav li a.active {
    color: var(--color-white);
    border-bottom-color: var(--color-teal);
}

.admin-topbar-logout {
    font-size: 13px;
    color: var(--color-gray-600);
    text-decoration: none;
    white-space: nowrap;
    transition: color 0.2s;
}

.admin-topbar-logout:hover {
    color: var(--color-red);
}

.admin-main {
    flex: 1;
    padding: 0 3rem;
    width: 90%;
    margin: auto;

    h1 {
        font-size: 22px;
        font-weight: 600;
        color: var(--primary-color);
        text-align: left;
        margin-bottom: 28px;
        font-family: 'Helvetica Neue', Arial, sans-serif;
    }
}

.admin-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;

    h1 {
        font-size: 22px;
        font-weight: 600;
        color: var(--primary-color);
        margin: 0;
        text-align: left;

        span {
            font-size: 15px;
            font-weight: 400;
            color: var(--color-gray-500);
            margin-left: 8px;
        }
    }
}

/* =============================================
   Barre de recherche
   ============================================= */
.admin-search-wrapper {
    margin-bottom: 16px;
    position: relative;
    max-width: 360px;

    input {
        width: 100%;
        padding: 9px 36px 9px 14px;
        border: 1px solid var(--color-border);
        border-radius: 6px;
        font-size: 14px;
        color: var(--primary-color);
        background: var(--color-white);
        box-sizing: border-box;
        transition: border-color 0.2s, box-shadow 0.2s;
    }

    input:focus {
        outline: none;
        border-color: var(--color-teal);
        box-shadow: 0 0 0 3px var(--color-teal-focus);
    }

    &::after {
        content: '🔍';
        position: absolute;
        right: 10px;
        top: 50%;
        transform: translateY(-50%);
        font-size: 13px;
        pointer-events: none;
    }
}

.search-empty {
    display: none;
    padding: 20px;
    text-align: center;
    color: var(--color-gray-600);
    font-size: 14px;
    background: var(--color-white);
    border-radius: 0 0 10px 10px;
}

/* =============================================
   Colonnes triables
   ============================================= */

.admin-table {
    thead th.sortable {
        cursor: pointer;
        user-select: none;
    }

    thead th.sortable:hover {
        background: var(--color-sidebar-hover);
    }

    thead th .sort-icon {
        display: inline-block;
        margin-left: 6px;
        opacity: 0.35;
        font-size: 11px;
    }

    thead th.sort-asc .sort-icon,
    thead th.sort-desc .sort-icon {
        opacity: 1;
        color: var(--color-teal);
    }
}

/* =============================================
   Table QCM
   ============================================= */
.qrm-table {
    .col-check {
        text-align: center;
        width: 40px;
    }

    .col-module {
        white-space: nowrap;
        max-width: 140px;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .col-question {
        max-width: 260px;

        ol {
            margin: 0;
            padding-left: 18px;
            font-size: 12px;
            color: var(--color-gray-700);
            line-height: 170%;
        }
    }
}

ul.chapter-list {
    margin: 0;
    padding-left: 18px;
    font-size: 12px;
    color: var(--color-gray-700);
    line-height: 180%;
    list-style-type: none;
}

.text-muted {
    color: var(--color-gray-placeholder);
    list-style: none;
}

.answer-toggle {
    width: 17px;
    height: 17px;
    cursor: pointer;
    accent-color: var(--color-green-check);
}

.answer-toggle:disabled {
    opacity: 0.5;
    cursor: wait;
}

.check {
    font-size: 15px;
    font-weight: 700;
}

.check-yes {
    color: var(--color-green-check);
}

.check-no {
    color: var(--color-gray-400);
}

.badge-type-qrm {
    background: var(--color-badge-qrm-bg);
    color: var(--color-badge-qrm-text);
}

.badge-type-qru {
    background: var(--color-badge-qru-bg);
    color: var(--color-badge-qru-text);
}

/* =============================================
   Dashboard — Stat cards
   ============================================= */
.admin-stats {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
}

.stat-card {
    background: var(--color-white);
    border-radius: 10px;
    padding: 28px 32px;
    min-width: 200px;
    flex: 1;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.07);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    border-top: 4px solid var(--color-teal);
    transition: box-shadow 0.2s;

    &:hover {
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    }
}

.stat-number {
    font-size: 42px;
    font-weight: 700;
    color: var(--primary-color);
    line-height: 100%;
}

.stat-label {
    font-size: 14px;
    color: var(--color-gray-600);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stat-card .btn {
    margin-top: 8px;
    font-size: 12px;
}

/* =============================================
   Tableaux
   ============================================= */

.admin-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--color-white);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.07);
    font-size: 14px;

    thead {
        background: var(--primary-color);
        color: var(--color-white);
    }

    thead th {
        padding: 14px 16px;
        text-align: left;
        font-weight: 600;
        font-size: 12px;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }

    tbody tr {
        border-bottom: 1px solid var(--color-bg-admin);
        transition: background 0.15s;
    }

    tbody tr:last-child {
        border-bottom: none;
    }

    tbody tr:hover {
        background: var(--color-bg-card);
    }

    tbody td {
        padding: 13px 16px;
        color: var(--color-navy);
        vertical-align: middle;
    }

    .col-actions {
        white-space: nowrap;
        text-align: center;

        form {
            margin: 0;
        }
    }
}

/* =============================================
   Badges
   ============================================= */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}

.badge-correct {
    background: var(--color-success-bg);
    color: var(--color-success-text);
}

.badge-locked {
    background: var(--color-danger-bg);
    color: var(--color-danger-text);
}

.badge-ready {
    background: var(--color-warning-bg);
    color: var(--color-warning-text);
}

.badge-running {
    background: var(--color-info-bg);
    color: var(--color-info-text);
}

.badge-done {
    background: var(--color-success-bg);
    color: var(--color-success-text);
}

/* =============================================
   Boutons admin
   ============================================= */
.admin-form {
    background: var(--color-white);
    border-radius: 10px;
    padding: 32px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.07);

    .row {
        display: flex;
        gap: 24px;
        flex-wrap: wrap;
    }

    .col-md-6 {
        flex: 1;
        min-width: 280px;
        box-sizing: border-box;
    }

    .col-md-12 {
        flex: 0 0 100%;
        box-sizing: border-box;
    }

    fieldset {
        border: 1px solid var(--color-border-light);
        border-radius: 8px;
        padding: 20px 24px;
        margin-bottom: 24px;
    }

    legend {
        font-size: 13px;
        font-weight: 600;
        color: var(--color-teal);
        text-transform: uppercase;
        letter-spacing: 1px;
        padding: 0 8px;
    }

    .form-section {
        margin-bottom: 24px;
    }

    .form-section h3 {
        font-size: 14px;
        font-weight: 600;
        color: var(--color-teal);
        text-transform: uppercase;
        letter-spacing: 1px;
        margin-bottom: 16px;
        padding-bottom: 8px;
        border-bottom: 2px solid var(--color-bg-admin);
    }

    .form-group {
        margin-bottom: 16px;
    }

    .form-row {
        display: flex;
        gap: 16px;
    }

    .form-row .form-group {
        flex: 1;
    }

    label {
        display: block;
        font-size: 13px;
        font-weight: 500;
        color: var(--color-navy);
        margin-bottom: 6px;
    }

    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="datetime-local"],
    select,
    textarea,
    .form-control {
        width: 100%;
        padding: 9px 13px;
        border: 1px solid var(--color-border);
        border-radius: 6px;
        font-size: 14px;
        color: var(--primary-color);
        background: var(--color-white);
        transition: border-color 0.2s, box-shadow 0.2s;
        box-sizing: border-box;
    }

    input:focus,
    select:focus,
    textarea:focus,
    .form-control:focus {
        outline: none;
        border-color: var(--color-teal);
        box-shadow: 0 0 0 3px var(--color-teal-focus);
    }

    textarea {
        resize: vertical;
        font-size: 13px;
        line-height: 160%;
    }

    select {
        appearance: auto;
    }

    small {
        display: block;
        font-size: 12px;
        color: var(--color-gray-600);
        margin-top: 4px;
    }

    .form-check {
        display: flex;
        align-items: center;
        gap: 8px;
    }

    .form-check label {
        margin-bottom: 0;
        cursor: pointer;
    }

    .form-check input[type="checkbox"] {
        width: 16px;
        height: 16px;
        cursor: pointer;
        accent-color: var(--color-teal);
    }
}

/* Ligne réponse QCM */
.answer-row {
    display: flex;
    align-items: flex-end;
    gap: 16px;
    padding: 12px;
    background: var(--color-bg-card);
    border-radius: 6px;
    margin-bottom: 10px;
    border: 1px solid var(--color-border-light);
}

.answer-text {
    flex: 1;
    margin-bottom: 0 !important;
}

.answer-bool {
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    margin-bottom: 0 !important;
    padding-bottom: 2px;
}

.answer-bool label {
    margin-bottom: 0;
    font-size: 13px;
    color: var(--color-green-check);
    font-weight: 500;
}

/* Actions bas de formulaire */
.form-actions {
    display: flex;
    gap: 12px;
    align-items: center;
    padding-top: 20px;
    border-top: 1px solid var(--color-bg-admin);
    margin-top: 24px;
}

/* =============================================
   Modale fiche client
   ============================================= */
.admin-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.admin-modal[aria-hidden="false"] {
    display: flex;
}

.admin-modal-backdrop {
    position: absolute;
    inset: 0;
    background: var(--color-overlay);
}

.admin-modal-dialog {
    position: relative;
    background: var(--color-white);
    border-radius: 10px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.18);
    width: 90%;
    max-width: 760px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.admin-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 28px;
    border-bottom: 1px solid var(--color-bg-admin);
    background: var(--primary-color);
}

.admin-modal-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--color-white);
    margin: 0;
}

.admin-modal-close {
    background: none;
    border: none;
    color: var(--color-gray-400);
    font-size: 22px;
    line-height: 100%;
    cursor: pointer;
    padding: 0 4px;
    transition: color 0.2s;
}

.admin-modal-close:hover {
    color: var(--color-white);
}

.admin-modal-body {
    padding: 24px 28px;
    overflow-y: auto;
    flex: 1;
}

.modal-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.modal-section {
    background: var(--color-bg-card);
    border-radius: 8px;
    padding: 16px 20px;
    border: 1px solid var(--color-border-light);

    h3 {
        font-size: 11px;
        font-weight: 700;
        color: var(--color-teal);
        text-transform: uppercase;
        letter-spacing: 1px;
        margin: 0 0 12px 0;
    }

    dl {
        margin: 0;
        display: grid;
        grid-template-columns: auto 1fr;
        gap: 6px 12px;
        align-items: baseline;
    }

    dt {
        font-size: 12px;
        font-weight: 600;
        color: var(--color-gray-600);
        white-space: nowrap;
    }

    dd {
        font-size: 13px;
        color: var(--primary-color);
        margin: 0;
        word-break: break-word;
    }
}

.admin-modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 28px;
    border-top: 1px solid var(--color-bg-admin);
    background: var(--color-bg-card);
}
