/* ============================================================
   EquitationBrest — Admin v2
   Styles globaux
   ============================================================ */

/* --- Variables -------------------------------------------- */
:root {
  --sidebar-bg:       #0F172A;
  --sidebar-text:     #94A3B8;
  --sidebar-hover:    #1E293B;
  --sidebar-active:   #6366F1;
  --sidebar-width:    240px;

  --primary:          #6366F1;
  --primary-hover:    #4F46E5;
  --success:          #10B981;
  --danger:           #EF4444;
  --warning:          #F59E0B;
  --info:             #3B82F6;

  --body-bg:          #F1F5F9;
  --card-bg:          #FFFFFF;
  --text:             #1E293B;
  --text-muted:       #64748B;
  --border:           #E2E8F0;

  --shadow:    0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-lg: 0 10px 25px rgba(0,0,0,.08), 0 4px 10px rgba(0,0,0,.04);

  --radius:    8px;
  --radius-lg: 12px;
}

/* --- Reset ------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--body-bg);
  color: var(--text);
  line-height: 1.6;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; display: block; }

/* ============================================================
   PAGE DE LOGIN
   ============================================================ */
.login-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 100vh;
}

.login-brand {
  background: linear-gradient(160deg, #0F172A 0%, #1B3A5C 55%, #312E81 100%);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 64px 56px;
  color: #fff;
}

.login-brand-icon {
  font-size: 3.5rem;
  margin-bottom: 24px;
}

.login-brand h1 {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 12px;
}

.login-brand p {
  color: rgba(255,255,255,.6);
  font-size: 1rem;
  line-height: 1.6;
  max-width: 320px;
}

.login-brand-features {
  margin-top: 40px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-brand-features span {
  display: flex;
  align-items: center;
  gap: 10px;
  color: rgba(255,255,255,.75);
  font-size: 0.9rem;
}

.login-brand-features span::before {
  content: '✓';
  background: rgba(99,102,241,.4);
  color: #A5B4FC;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  flex-shrink: 0;
}

.login-form-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 40px;
  background: #fff;
}

.login-form-inner {
  width: 100%;
  max-width: 360px;
}

.login-form-inner h2 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}

.login-form-inner > p {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-bottom: 32px;
}

@media (max-width: 768px) {
  .login-split { grid-template-columns: 1fr; }
  .login-brand  { display: none; }
  .login-form-panel { padding: 40px 24px; }
}

/* ============================================================
   LAYOUT ADMIN (sidebar + contenu)
   ============================================================ */
.admin-layout {
  display: flex;
  min-height: 100vh;
}

/* --- Sidebar ---------------------------------------------- */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
}

.sidebar-header {
  padding: 24px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}

.sidebar-header h2 {
  color: #FFFFFF;
  font-size: 1rem;
  font-weight: 700;
}

.sidebar-header p {
  color: var(--sidebar-text);
  font-size: 0.75rem;
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  list-style: none;
}

.sidebar-nav li a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  color: var(--sidebar-text);
  font-size: 0.9rem;
  transition: background .15s, color .15s;
  text-decoration: none;
}

.sidebar-nav li a:hover {
  background: var(--sidebar-hover);
  color: #FFFFFF;
}

.sidebar-nav li a.active {
  background: rgba(99,102,241,.15);
  color: var(--sidebar-active);
  border-right: 3px solid var(--sidebar-active);
}

.sidebar-nav .nav-icon {
  font-size: 1.1rem;
  width: 20px;
  text-align: center;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,.06);
}

.sidebar-footer a {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--sidebar-text);
  font-size: 0.85rem;
  text-decoration: none;
}

.sidebar-footer a:hover { color: var(--danger); }

/* --- Contenu principal ------------------------------------ */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  padding: 0 32px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.page-body {
  padding: 32px;
  flex: 1;
}

/* ============================================================
   COMPOSANTS
   ============================================================ */

/* --- Cartes ----------------------------------------------- */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

/* --- Statistiques (tableau de bord) ----------------------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-icon {
  font-size: 2rem;
  width: 52px;
  height: 52px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(99,102,241,.1);
}

.stat-info p { color: var(--text-muted); font-size: 0.8rem; }

.stat-info strong {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}

/* --- Formulaires ------------------------------------------ */
.form-group { margin-bottom: 20px; }

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

.form-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 4px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="url"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--text);
  background: var(--card-bg);
  transition: border-color .2s, box-shadow .2s;
  outline: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,.15);
}

textarea { min-height: 140px; resize: vertical; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* Champ mot de passe avec bouton afficher/cacher */
.input-group {
  position: relative;
}

.input-group input { padding-right: 44px; }

.input-group-btn {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 1rem;
  padding: 0;
  line-height: 1;
}

.input-group-btn:hover { color: var(--text); }

/* Cases à cocher */
.checkbox-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.checkbox-group input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

/* --- Boutons --------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  border: none;
  transition: opacity .15s, transform .1s;
  text-decoration: none;
  line-height: 1;
}

.btn:hover { opacity: .88; text-decoration: none; }
.btn:active { transform: scale(.98); }

.btn-primary   { background: var(--primary);  color: #fff; }
.btn-success   { background: var(--success);  color: #fff; }
.btn-danger    { background: var(--danger);   color: #fff; }
.btn-warning   { background: var(--warning);  color: #fff; }
.btn-secondary { background: var(--border);   color: var(--text); }

.btn-sm { padding: 6px 12px; font-size: 0.8rem; }

.btn-full { width: 100%; justify-content: center; padding: 12px; }

/* --- Alertes --------------------------------------------- */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.alert-success { background: #DCFCE7; color: #166534; border: 1px solid #BBF7D0; }
.alert-error   { background: #FEE2E2; color: #991B1B; border: 1px solid #FECACA; }
.alert-warning { background: #FEF9C3; color: #854D0E; border: 1px solid #FDE047; }
.alert-info    { background: #DBEAFE; color: #1E40AF; border: 1px solid #BFDBFE; }

/* --- Tableaux -------------------------------------------- */
.table-wrapper {
  overflow: visible;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

thead th {
  text-align: left;
  padding: 10px 16px;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  border-bottom: 1px solid var(--border);
  background: #F8FAFC;
}

tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #F8FAFC; }

.table-actions { display: flex; gap: 8px; }

/* --- Badges ---------------------------------------------- */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 500;
}

.badge-primary { background: rgba(99,102,241,.12); color: var(--primary); }
.badge-success { background: rgba(16,185,129,.12);  color: var(--success); }
.badge-danger  { background: rgba(239,68,68,.12);   color: var(--danger); }
.badge-warning { background: rgba(245,158,11,.12);  color: var(--warning); }
.badge-neutral { background: var(--border);          color: var(--text-muted); }

/* --- Icônes de statut (validation) ----------------------- */
.status-icon {
  font-size: 1rem;
  line-height: 1;
  cursor: default;
}

/* --- Texte tronqué avec tooltip ========================== */
/* Wrapper externe : porte le tooltip, contraint la largeur   */
.trunc-wrap {
  position: relative;
  display: inline-block;
  vertical-align: middle;
  max-width: 200px;
  cursor: help;
}
/* Tableau de bord : blocs empilés + plus de place pour ~70 caractères */
.dashboard-blocks {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  margin-top: 8px;
}
.dashboard-blocks .trunc-wrap {
  max-width: 380px;
}
/* Span interne : troncature CSS visuelle                     */
.trunc {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

/* ============================================================
   TOOLTIP CSS UNIVERSEL  [data-tooltip]
   S'applique à tous les éléments portant data-tooltip=""
   ============================================================ */
[data-tooltip] { position: relative; }

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.92);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 400;
  font-family: 'Segoe UI', system-ui, sans-serif;
  line-height: 1.45;
  padding: 5px 10px;
  border-radius: 5px;
  white-space: normal;
  max-width: 240px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
  pointer-events: none;
  opacity: 0;
  transition: opacity .15s ease;
  z-index: 9999;
}

/* Petite flèche */
[data-tooltip]::before {
  content: '';
  position: absolute;
  bottom: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  border: 4px solid transparent;
  border-top-color: rgba(15, 23, 42, 0.92);
  pointer-events: none;
  opacity: 0;
  transition: opacity .15s ease;
  z-index: 9999;
}

[data-tooltip]:hover::after,
[data-tooltip]:hover::before { opacity: 1; }

/* ============================================================
   RENDU QUILL — blockquote (citation)
   ============================================================ */
.content-preview blockquote {
  border-left: 4px solid var(--border);
  padding: 4px 0 4px 20px;
  margin: 10px 0;
  color: var(--text-muted);
  font-style: italic;
}

/* --- Compteurs colorés dans le dashboard ----------------- */
.count-ok   { color: var(--success); font-weight: 600; }
.count-wait { color: var(--warning); font-weight: 600; }
.count-ko   { color: var(--danger);  font-weight: 600; }

/* --- Icônes de contenu lié (sujets) ---------------------- */
.content-icon {
  font-size: 1.1rem;
  text-decoration: none;
  opacity: 1;
}
.content-icon.absent {
  opacity: 0.25;
  cursor: default;
  pointer-events: none;
}

/* --- Pagination ------------------------------------------ */
.pagination {
  display: flex;
  gap: 4px;
  justify-content: center;
  margin-top: 24px;
}

.pagination a, .pagination span {
  padding: 6px 12px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  border: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
}

.pagination a:hover { background: var(--body-bg); }
.pagination .current { background: var(--primary); color: #fff; border-color: var(--primary); }

/* --- Miniature YouTube ----------------------------------- */
.yt-thumb {
  width: 80px;
  height: 45px;
  object-fit: cover;
  border-radius: 4px;
}

/* --- Image article --------------------------------------- */
.article-thumb {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: var(--radius);
}

/* --- Vide (liste vide) ----------------------------------- */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.empty-state p { font-size: 0.9rem; margin-top: 8px; }

/* --- Séparateur de section dans formulaire --------------- */
.form-section {
  margin-bottom: 28px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.form-section:last-child { border-bottom: none; }

.form-section-title {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  margin-bottom: 16px;
}

/* ============================================================
   UTILITAIRES
   ============================================================ */
.text-muted   { color: var(--text-muted); }
.text-danger  { color: var(--danger); }
.text-success { color: var(--success); }
.text-small   { font-size: 0.8rem; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.d-flex        { display: flex; }
.align-center  { align-items: center; }
.gap-2         { gap: 8px; }
.gap-3         { gap: 12px; }
.justify-between { justify-content: space-between; }

/* ============================================================
   WIDGET UPLOAD D'IMAGE
   ============================================================ */
.upload-widget { display: flex; flex-direction: column; gap: 12px; }

.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 28px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  background: #FAFAFA;
  position: relative;
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--primary);
  background: rgba(99,102,241,.04);
}

.upload-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.upload-zone-icon  { font-size: 2rem; margin-bottom: 6px; }
.upload-zone-label { font-size: 0.875rem; color: var(--text-muted); }
.upload-zone-label strong { color: var(--primary); }
.upload-zone-hint  { font-size: 0.75rem; color: var(--text-muted); margin-top: 4px; }

/* Prévisualisation */
.upload-preview {
  display: none;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  background: var(--body-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.upload-preview.visible { display: flex; }

.upload-preview img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: var(--radius);
  flex-shrink: 0;
}

.upload-preview-info { flex: 1; min-width: 0; }
.upload-preview-name {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.upload-preview-size { font-size: 0.78rem; color: var(--text-muted); margin-top: 2px; }

.upload-remove-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--danger);
  font-size: 1.1rem;
  padding: 4px;
  flex-shrink: 0;
}
.upload-remove-btn:hover { opacity: .7; }

/* ============================================================
   QUIZ BUILDER
   ============================================================ */
.quiz-empty {
  text-align: center;
  padding: 36px 24px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 0.875rem;
}

.question-block {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
  background: var(--card-bg);
}

.question-header {
  background: var(--body-bg);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
}

.question-number {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--primary);
}

.question-body { padding: 16px; }

.reponses-list {
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.reponse-block {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  transition: background .15s;
}

.reponse-block:last-child { border-bottom: none; }
.reponse-block.correcte   { background: rgba(16,185,129,.05); }

.reponse-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.reponse-row input[type="text"] { flex: 1; }

.correcte-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
  cursor: pointer;
  flex-shrink: 0;
  padding: 6px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--card-bg);
  transition: all .15s;
}

.correcte-label:hover            { border-color: var(--success); }
.correcte-label.active           { border-color: var(--success); background: rgba(16,185,129,.08); color: var(--success); font-weight: 600; }
.correcte-label input[type="checkbox"] { display: none; }

.reponse-explication {
  margin-top: 6px;
  padding-left: 2px;
}

.reponse-explication input {
  font-size: 0.82rem;
  color: var(--text-muted);
  background: transparent;
  border-color: transparent;
  padding: 4px 8px;
}

.reponse-explication input:focus {
  background: var(--card-bg);
  border-color: var(--border);
}

.reponse-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 1rem;
  padding: 4px 6px;
  border-radius: var(--radius);
  flex-shrink: 0;
  transition: color .15s, background .15s;
}
.reponse-remove:hover { color: var(--danger); background: rgba(239,68,68,.08); }
