/* ==================================================
   ADMIN STYLE — Boîte à Outils Moihte
   ================================================== */
:root {
    --dark:   #263040;
    --teal:   #44c3a4;
    --blue:   #305a74;
    --light:  #f4f6fa;
    --border: #dde2ec;
    --text:   #2d3547;
    --muted:  #6a737d;
    --red:    #e05252;
    --green:  #2dba7e;
    --warn:   #f0ad4e;
}

*, *::before, *::after { box-sizing: border-box; }
body {
    font-family: "Segoe UI", Arial, sans-serif;
    background: var(--light);
    color: var(--text);
    margin: 0; padding: 0;
    min-height: 100vh;
}
a { color: var(--teal); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── HEADER ───────────────────────────────────── */
.admin-header {
    background: var(--dark);
    color: #b0b8c9;
    padding: 0 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 58px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 12px rgba(0,0,0,.18);
}
.admin-header h1 {
    font-size: 1.1em;
    font-weight: 700;
    color: #e0e8f0;
    margin: 0;
    letter-spacing: .01em;
}
.admin-header a.home-link {
    color: var(--teal);
    font-weight: 600;
    font-size: .95em;
}
.admin-header .header-right {
    display: flex;
    align-items: center;
    gap: 18px;
}
.admin-header .logout-btn {
    background: rgba(255,255,255,.08);
    color: #b0b8c9;
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 20px;
    padding: 5px 16px;
    font-size: .9em;
    cursor: pointer;
    transition: background .2s, color .2s;
    text-decoration: none;
    font-family: inherit;
}
.admin-header .logout-btn:hover {
    background: rgba(255,255,255,.16);
    color: #fff;
    text-decoration: none;
}

/* ── CONTENU PRINCIPAL ────────────────────────── */
.admin-wrap {
    max-width: 1100px;
    margin: 0 auto;
    padding: 36px 28px 60px;
}

/* ── TITRES ───────────────────────────────────── */
.page-title {
    font-size: 1.5em;
    font-weight: 700;
    color: var(--blue);
    margin: 0 0 6px;
}
.page-sub {
    color: var(--muted);
    font-size: .97em;
    margin: 0 0 32px;
}

/* ── BOUTONS ──────────────────────────────────── */
.btn {
    display: inline-block;
    padding: 7px 20px;
    border-radius: 20px;
    font-size: .95em;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: background .18s, color .18s, box-shadow .18s;
    font-family: inherit;
    text-decoration: none;
    line-height: 1.4;
}
.btn-primary { background: var(--teal); color: #fff; }
.btn-primary:hover { background: #33a889; color: #fff; text-decoration: none; }
.btn-secondary { background: #e2e7ee; color: var(--text); }
.btn-secondary:hover { background: #cdd5e0; }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #c43a3a; }
.btn-sm { padding: 4px 13px; font-size: .87em; }
.btn-icon { padding: 5px 10px; font-size: 1em; border-radius: 8px; }

/* ── CARTES ESPACES ───────────────────────────── */
.matiere-group { margin-bottom: 40px; }
.matiere-title {
    font-size: 1.13em;
    font-weight: 700;
    color: var(--blue);
    padding-bottom: 8px;
    border-bottom: 2px solid var(--border);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.matiere-title .matiere-count {
    background: var(--dark);
    color: #73d7ee;
    font-size: .75em;
    padding: 2px 9px;
    border-radius: 20px;
    font-weight: 600;
}

.space-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 18px;
}
.space-card {
    background: #fff;
    border-radius: 14px;
    padding: 20px 22px 16px;
    box-shadow: 0 2px 12px rgba(30,60,100,.07);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: box-shadow .2s;
}
.space-card:hover { box-shadow: 0 4px 20px rgba(30,60,100,.12); }

.space-card-header {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}
.space-logo {
    width: 48px; height: 48px;
    border-radius: 10px;
    object-fit: cover;
    background: #e2e7ee;
    flex-shrink: 0;
}
.space-logo-placeholder {
    width: 48px; height: 48px;
    border-radius: 10px;
    background: var(--dark);
    color: var(--teal);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4em;
    font-weight: 700;
    flex-shrink: 0;
}
.space-info { flex: 1; min-width: 0; }
.space-title {
    font-weight: 700;
    font-size: 1.05em;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.space-niveau {
    font-size: .88em;
    color: var(--muted);
    margin-top: 2px;
}

.space-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: .78em;
    font-weight: 700;
    letter-spacing: .03em;
}
.badge-active   { background: #e7f9f2; color: var(--green); }
.badge-inactive { background: #fef3e2; color: var(--warn); }

.space-token {
    background: var(--light);
    border-radius: 8px;
    padding: 7px 12px;
    font-size: .88em;
    display: flex;
    align-items: center;
    gap: 8px;
}
.space-token code {
    flex: 1;
    font-size: 1em;
    color: var(--blue);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: "Courier New", monospace;
}
.copy-btn {
    background: none;
    border: none;
    color: var(--teal);
    cursor: pointer;
    padding: 2px 5px;
    font-size: 1em;
    border-radius: 5px;
    transition: background .15s;
}
.copy-btn:hover { background: #e2e7ee; }

.space-url {
    font-size: .82em;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.space-url a { color: var(--teal); font-weight: 600; }

.space-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 2px;
}

/* ── FORMULAIRES ──────────────────────────────── */
.form-card {
    background: #fff;
    border-radius: 16px;
    padding: 32px 36px;
    box-shadow: 0 2px 14px rgba(30,60,100,.07);
    border: 1px solid var(--border);
    max-width: 720px;
}
.form-section-title {
    font-size: 1em;
    font-weight: 700;
    color: var(--blue);
    border-bottom: 1px solid var(--border);
    padding-bottom: 8px;
    margin: 28px 0 16px;
}
.form-section-title:first-child { margin-top: 0; }

.form-row { margin-bottom: 20px; }
.form-row label {
    display: block;
    font-weight: 600;
    font-size: .93em;
    color: var(--text);
    margin-bottom: 6px;
}
.form-row label span.req { color: var(--red); }
.form-row input[type=text],
.form-row input[type=number],
.form-row input[type=file],
.form-row textarea,
.form-row select {
    width: 100%;
    border: 1.5px solid var(--border);
    border-radius: 9px;
    padding: 9px 14px;
    font-size: .97em;
    font-family: inherit;
    color: var(--text);
    background: #fff;
    transition: border-color .18s;
    outline: none;
}
.form-row input:focus, .form-row textarea:focus, .form-row select:focus {
    border-color: var(--teal);
}
.form-row textarea { min-height: 90px; resize: vertical; line-height: 1.5; }
.form-row .hint {
    font-size: .82em;
    color: var(--muted);
    margin-top: 5px;
}
.form-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-check { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.form-check input { width: auto; cursor: pointer; }

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 30px;
    flex-wrap: wrap;
}

/* ── ALERTES ──────────────────────────────────── */
.alert {
    padding: 12px 18px;
    border-radius: 9px;
    margin-bottom: 20px;
    font-size: .97em;
    border-left: 4px solid transparent;
}
.alert-success { background: #e7f9f2; border-color: var(--green); color: #1d7c56; }
.alert-error   { background: #fdeaea; border-color: var(--red);   color: #9b2222; }
.alert-info    { background: #e8f4fd; border-color: var(--teal);  color: var(--blue); }

/* ── TABLE STATS ──────────────────────────────── */
table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(30,60,100,.07);
    margin-bottom: 24px;
}
th {
    background: var(--dark);
    color: #c0cde0;
    padding: 10px 16px;
    text-align: left;
    font-size: .9em;
    font-weight: 600;
    letter-spacing: .04em;
}
td {
    padding: 8px 16px;
    border-bottom: 1px solid var(--border);
    font-size: .93em;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f7f9fc; }
td.center { text-align: center; }

.stat-card {
    background: #fff;
    border-radius: 14px;
    padding: 20px 22px;
    box-shadow: 0 2px 12px rgba(30,60,100,.07);
    border: 1px solid var(--border);
    text-align: center;
    min-width: 130px;
}
.stat-card .stat-label { font-size: .88em; color: var(--muted); margin-bottom: 6px; }
.stat-card .stat-val   { font-size: 2em; font-weight: 700; color: var(--blue); }
.stat-card .stat-icon  { font-size: 1.4em; margin-bottom: 4px; }
.stats-row { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 32px; }

details summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--blue);
    padding: 8px 0;
    font-size: .97em;
}
details[open] summary { color: var(--teal); }

/* ── TOKEN REGEN ──────────────────────────────── */
.token-field-wrap { display: flex; gap: 8px; }
.token-field-wrap input { flex: 1; font-family: "Courier New", monospace; }

/* ── RESPONSIVE ───────────────────────────────── */
@media (max-width: 700px) {
    .admin-wrap { padding: 20px 14px 40px; }
    .form-card { padding: 22px 16px; }
    .form-cols { grid-template-columns: 1fr; }
    .space-cards { grid-template-columns: 1fr; }
    .stats-row { flex-direction: column; }
}

/* ── DIVERS ───────────────────────────────────── */
.empty-state {
    text-align: center;
    color: var(--muted);
    padding: 48px 20px;
    font-size: 1.05em;
}
.empty-state .empty-icon { font-size: 2.5em; margin-bottom: 10px; }

.sep { display: flex; align-items: center; gap: 14px; margin: 32px 0 24px; }
.sep hr { flex: 1; border: none; border-top: 1px solid var(--border); }
.sep span { color: var(--muted); font-size: .88em; white-space: nowrap; }
