/* =========================
   Base admin
========================= */

.admin-section {
    background: var(--bg);
}

/* =========================
   Conteneurs admin
========================= */

.admin-container-wide {
    max-width: 1680px;
    width: 100%;
}

.admin-form-wide {
    max-width: 1040px;
}

/* =========================
   Statistiques
========================= */

.admin-stats-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    background: #ffffff;
    border: 1px solid var(--border);
    padding: 20px;
}

.stat-card span {
    display: block;
    color: var(--muted);
    font-size: 14px;
    margin-bottom: 8px;
}

.stat-card strong {
    display: block;
    font-size: 30px;
    line-height: 1;
    color: var(--text);
}

.session-admin-stats {
    margin-bottom: 0;
}

/* =========================
   Panneaux admin
========================= */

.admin-panel {
    background: #ffffff;
    border: 1px solid var(--border);
    padding: 24px;
    margin-bottom: 28px;
}

.admin-container-wide .admin-panel {
    width: 100%;
    padding: 20px;
}

.admin-panel h2 {
    margin: 0;
}

.admin-panel-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
    margin-bottom: 18px;
}

.admin-panel-title {
    margin-bottom: 16px;
}

.admin-panel-title .kicker {
    margin-bottom: 6px;
}

.admin-panel-title h2 {
    margin: 0;
    font-size: 26px;
    line-height: 1.2;
}

.admin-panel-toolbar {
    display: flex;
    justify-content: flex-start;
    margin-bottom: 18px;
}

.admin-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.admin-actions form {
    margin: 0;
}

/* =========================
   Dashboard - sections colorées
========================= */

.dashboard-panel {
    position: relative;
    overflow: hidden;
    border-left: 5px solid var(--border);
}

.dashboard-panel > * {
    position: relative;
    z-index: 1;
}

.dashboard-panel-pilotage {
    border-left-color: #0b7a53;
    background: linear-gradient(135deg, rgba(11, 122, 83, .075), #ffffff 42%);
}

.dashboard-panel-inscriptions {
    border-left-color: #2563eb;
    background: linear-gradient(135deg, rgba(37, 99, 235, .075), #ffffff 42%);
}

.dashboard-panel-devis {
    border-left-color: #7c3aed;
    background: linear-gradient(135deg, rgba(124, 58, 237, .075), #ffffff 42%);
}

.dashboard-panel-messages {
    border-left-color: #0891b2;
    background: linear-gradient(135deg, rgba(8, 145, 178, .075), #ffffff 42%);
}

.dashboard-panel-stats {
    border-left-color: #f59e0b;
    background: linear-gradient(135deg, rgba(245, 158, 11, .085), #ffffff 42%);
}

.dashboard-panel-security {
    border-left-color: #b42318;
    background: linear-gradient(135deg, rgba(180, 35, 24, .075), #ffffff 42%);
}

.dashboard-panel-activity {
    border-left-color: #475569;
    background: linear-gradient(135deg, rgba(71, 85, 105, .075), #ffffff 42%);
}

.dashboard-panel-clicks {
    border-left-color: #16a34a;
    background: linear-gradient(135deg, rgba(22, 163, 74, .075), #ffffff 42%);
}

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

.table-wrap {
    width: 100%;
    overflow-x: auto;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.admin-table th,
.admin-table td {
    border-bottom: 1px solid var(--border);
    padding: 12px 10px;
    text-align: left;
    vertical-align: top;
}

.admin-table th {
    background: #f8fafc;
    color: var(--text);
    font-weight: 700;
}

.admin-table code {
    background: #f1f5f9;
    padding: 3px 6px;
    font-size: 13px;
}

/* Tables compactes dans les pages larges */
.admin-container-wide .admin-table {
    width: 100%;
    min-width: 0;
    table-layout: auto;
    font-size: 13px;
}

.admin-container-wide .admin-table th,
.admin-container-wide .admin-table td {
    padding: 9px 8px;
    line-height: 1.35;
}

.admin-container-wide .admin-table th {
    white-space: nowrap;
}

/* =========================
   Texte tableau
========================= */

.table-muted {
    display: inline-block;
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.4;
}

.admin-container-wide .table-muted {
    font-size: 12px;
    line-height: 1.3;
}

.ua {
    max-width: 420px;
    color: var(--muted);
    font-size: 13px;
    word-break: break-word;
}

.message-cell {
    min-width: 260px;
    max-width: 520px;
    white-space: normal;
}

.unread-row {
    background: #fffdf5;
}

.highlight-row {
    outline: 3px solid var(--brand);
    background: #f0fdf4;
}

/* =========================
   Badges / statuts
========================= */

.status {
    display: inline-block;
    padding: 4px 8px;
    font-size: 13px;
    font-weight: 700;
    border: 1px solid var(--border);
}

.admin-container-wide .status {
    padding: 3px 7px;
    font-size: 12px;
}

.status.active {
    color: var(--success);
    border-color: #a6d8bd;
    background: #f0fdf4;
}

.status.inactive {
    color: var(--danger);
    border-color: #f4b4ab;
    background: #fff7f5;
}

.status.warning {
    color: #92400e;
    border-color: #facc15;
    background: #fffbeb;
}

.status.danger {
    color: #b42318;
    border-color: #fda29b;
    background: #fee4e2;
}

/* =========================
   Boutons / actions
========================= */

.btn.small {
    padding: 8px 11px;
    font-size: 13px;
}

.admin-container-wide .btn.small {
    padding: 6px 8px;
    font-size: 12px;
}

.btn.danger {
    background: #b42318;
    border-color: #b42318;
    color: #ffffff;
}

.btn.danger:hover {
    background: #8f1c13;
    border-color: #8f1c13;
}

.row-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.admin-container-wide .row-actions {
    gap: 5px;
}

.row-actions form {
    margin: 0;
}

.order-actions {
    display: flex;
    gap: 4px;
    margin-top: 6px;
}

.order-actions form {
    margin: 0;
}

.link-button {
    border: 1px solid var(--border);
    background: #ffffff;
    color: var(--text);
    cursor: pointer;
    padding: 3px 8px;
    font-weight: 700;
}

.link-button:hover {
    border-color: var(--brand);
    color: var(--brand);
}

/* =========================
   Formulaires admin
========================= */

.admin-form {
    background: #ffffff;
    border: 1px solid var(--border);
    padding: 28px;
}

.admin-form-wide .admin-form {
    padding: 30px;
}

.form-row {
    margin-bottom: 18px;
}

.form-row label {
    display: block;
    font-weight: 700;
    margin-bottom: 7px;
}

.form-row input,
.form-row textarea,
.form-row select {
    width: 100%;
    border: 1px solid var(--border);
    padding: 12px;
    font: inherit;
    background: #ffffff;
}

.form-row input:focus,
.form-row textarea:focus,
.form-row select:focus {
    outline: 2px solid rgba(11, 122, 83, .22);
    border-color: var(--brand);
}

.form-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.admin-form-wide .form-grid-2 {
    gap: 22px;
}

.admin-form-wide .form-row input,
.admin-form-wide .form-row textarea,
.admin-form-wide .form-row select {
    min-height: 46px;
}

.admin-form-wide .form-row textarea {
    min-height: 180px;
}

.checkbox-row {
    display: flex;
    align-items: flex-end;
}

.checkbox-row label {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 46px;
    margin-bottom: 0;
}

.checkbox-row input {
    width: auto;
}

.help-text {
    display: block;
    margin-top: 6px;
    color: var(--muted);
    font-size: 13px;
}

.form-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 22px;
}

/* =========================
   Images formations admin
========================= */

.admin-thumb {
    display: block;
    width: 92px;
    height: 56px;
    object-fit: cover;
    border: 1px solid var(--border);
    background: #eef2f5;
}

.current-image-preview {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 10px;
    padding: 10px;
    border: 1px solid var(--border);
    background: #f8fafc;
}

.current-image-preview img {
    width: 120px;
    height: 70px;
    object-fit: cover;
    border: 1px solid var(--border);
}

.current-image-preview span {
    color: var(--muted);
    font-size: 14px;
}

.inline-delete-form {
    margin-top: 10px;
}

/* =========================
   Dashboard compact
========================= */

.admin-compact-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 22px;
    margin-bottom: 24px;
}

.admin-panel.compact {
    margin-bottom: 0;
}

.security-alert {
    border-left: 4px solid #b42318;
}

.security-ok {
    border-left: 4px solid var(--brand);
}

/* =========================
   Details repliables
========================= */

.admin-panel details {
    width: 100%;
}

.admin-panel summary {
    cursor: pointer;
    list-style: none;
    font-weight: 800;
    font-size: 1.15rem;
    color: var(--text);
}

.admin-panel summary::-webkit-details-marker {
    display: none;
}

.admin-panel summary::after {
    content: "+";
    float: right;
    font-size: 1.4rem;
    color: var(--brand);
}

.admin-panel details[open] summary::after {
    content: "−";
}

.details-content {
    margin-top: 18px;
}

/* =========================
   Éditeur description formation
========================= */

.editor-toolbar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 10px;
    padding: 10px;
    background: #f8fafc;
    border: 1px solid var(--border);
}

.editor-btn {
    border: 1px solid var(--border);
    background: #ffffff;
    color: var(--text);
    padding: 8px 10px;
    font: inherit;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}

.editor-btn:hover {
    border-color: var(--brand);
    color: var(--brand);
}

.rich-description-textarea {
    min-height: 260px;
    font-family: Consolas, Monaco, monospace;
    line-height: 1.55;
}

.editor-preview-box {
    margin-top: 16px;
    border: 1px solid var(--border);
    background: #ffffff;
}

.editor-preview-head {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 14px;
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
}

.editor-preview-head span {
    color: var(--muted);
    font-size: 13px;
}

.editor-preview-content {
    padding: 18px;
    color: var(--muted);
    line-height: 1.65;
}

.editor-preview-content h3,
.editor-preview-content h4 {
    color: var(--text);
    margin: 18px 0 8px;
    line-height: 1.25;
}

.editor-preview-content h3:first-child,
.editor-preview-content h4:first-child {
    margin-top: 0;
}

.editor-preview-content p {
    margin: 0 0 12px;
}

.editor-preview-content ul,
.editor-preview-content ol {
    margin: 10px 0 14px;
    padding-left: 22px;
}

.editor-preview-content li {
    margin-bottom: 6px;
}

.editor-preview-content blockquote {
    margin: 16px 0;
    padding: 14px 16px;
    border-left: 4px solid var(--brand);
    background: #f6fbf8;
    color: var(--text);
    font-weight: 600;
}

.editor-preview-content mark {
    background: #fef3c7;
    color: var(--text);
    padding: 0 3px;
}

.editor-preview-content hr {
    border: 0;
    border-top: 1px solid var(--border);
    margin: 18px 0;
}

.preview-empty {
    color: var(--muted);
    font-style: italic;
}

/* =========================
   Quota sessions admin
========================= */

.quota-admin-box {
    border: 1px solid var(--border);
    padding: 16px;
    margin-top: 18px;
    background: #fbfcfd;
}

.quota-admin-box strong {
    display: block;
    margin-bottom: 4px;
}

.quota-admin-box span {
    color: var(--muted);
}

.quota-admin-box.confirmed {
    border-color: #a6d8bd;
    background: #f0fdf4;
}

.quota-admin-box.pending {
    border-color: #facc15;
    background: #fffbeb;
}

/* =========================
   Responsive
========================= */

@media (max-width: 1400px) {
    .admin-stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 1000px) {
    .admin-stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .admin-compact-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 760px) {
    .admin-stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .admin-panel-head {
        align-items: flex-start;
        flex-direction: column;
    }

    .form-grid-2,
    .admin-form-wide .form-grid-2 {
        grid-template-columns: 1fr;
    }

    .row-actions {
        align-items: flex-start;
        flex-direction: column;
    }

    .admin-panel,
    .admin-form,
    .admin-form-wide .admin-form {
        padding: 20px;
    }

    .admin-form-wide {
        max-width: var(--max);
    }
}

@media (max-width: 560px) {
    .admin-stats-grid {
        grid-template-columns: 1fr;
    }

    .stat-card strong {
        font-size: 28px;
    }

    .editor-preview-head {
        flex-direction: column;
        gap: 4px;
    }
}