/* ═══════════════════════════════════════════════
   COMMON.CSS — Partagé entre doc et admin
   ═══════════════════════════════════════════════ */

/* ─── VARIABLES ─── */
:root {
  --primary: #00bfff;
  --dark: #22262d;
  --text: #374151;
  --text-light: #6b7280;
  --bg: #ffffff;
  --border: #e5e7eb;

  /* Sidebar sombre (partagée doc + admin) */
  --sidebar-bg: #1a1f27;
  --sidebar-text: rgba(255,255,255,0.75);
  --sidebar-text-light: rgba(255,255,255,0.45);
  --sidebar-border: rgba(255,255,255,0.1);
  --sidebar-hover-bg: rgba(255,255,255,0.06);
  --sidebar-input-bg: rgba(255,255,255,0.08);
  --sidebar-width: 280px;

  /* Contenu */
  --content-bg: #ffffff;
  --input-bg: #ffffff;
  --input-bg2: #fafafa;
  --toolbar-bg: #fafafa;
  --bottom-bar-bg: #fafafa;
  --modal-bg: #ffffff;

  /* Code */
  --code-bg: #f0f9ff;
  --code-color: #0369a1;
  --pre-bg: #1e293b;
  --pre-color: #e2e8f0;
  --blockquote-bg: #f0f9ff;
  --table-head-bg: #f8fafc;
  --table-hover-bg: #fafafa;
  --h2-border: #f0f9ff;
  --h3-color: #1f2937;
  --skeleton-1: #f0f0f0;
  --skeleton-2: #e0e0e0;
}

[data-theme="dark"] {
  --dark: #f1f5f9;
  --text: #cbd5e1;
  --text-light: #94a3b8;
  --bg: #0f172a;
  --border: #334155;

  --sidebar-bg: #0d1117;
  --sidebar-border: rgba(255,255,255,0.08);
  --sidebar-hover-bg: rgba(255,255,255,0.05);
  --sidebar-input-bg: rgba(255,255,255,0.07);

  --content-bg: #1e293b;
  --input-bg: #0f172a;
  --input-bg2: #0f172a;
  --toolbar-bg: #0f172a;
  --bottom-bar-bg: #0f172a;
  --modal-bg: #1e293b;

  --code-bg: #1e293b;
  --code-color: #67e8f9;
  --pre-bg: #000000;
  --pre-color: #e2e8f0;
  --blockquote-bg: rgba(0,191,255,0.08);
  --table-head-bg: #1e293b;
  --table-hover-bg: #1e293b;
  --h2-border: #1e293b;
  --h3-color: #e2e8f0;
  --skeleton-1: #1e293b;
  --skeleton-2: #334155;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Inter', sans-serif; color: var(--text); background: var(--bg); transition: background 0.2s, color 0.2s; }
input, textarea, select, button { font-family: inherit; }

/* ─── TOPBAR (barre admin en haut) ─── */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 500;
  height: 34px;
  background: #1a1f27;
  color: #e5e7eb;
  font-size: 12px;
  font-weight: 500;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.topbar a { color: var(--primary); text-decoration: none; font-weight: 600; }
.topbar a:hover { text-decoration: underline; }

/* ─── SIDEBAR SOMBRE ─── */
.sidebar-dark {
  background: var(--sidebar-bg);
  color: white;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: background 0.2s;
}
[data-theme="dark"] .sidebar-dark { background: #0d1117; }

.sidebar-dark-header {
  padding: 16px;
  border-bottom: 1px solid var(--sidebar-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.sidebar-dark-header img { height: 24px; width: auto; max-width: 160px; }

.sidebar-dark-section {
  padding: 12px 16px;
  border-bottom: 1px solid var(--sidebar-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.sidebar-dark-section h3 {
  font-size: 13px; font-weight: 600;
  color: var(--sidebar-text-light);
  text-transform: uppercase; letter-spacing: 0.05em;
}

.sidebar-dark-nav { flex: 1; overflow-y: auto; padding: 8px 0; }

.nav-item {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 16px; font-size: 13px; cursor: pointer;
  transition: background 0.15s;
  color: var(--sidebar-text);
}
.nav-item:hover { background: var(--sidebar-hover-bg); color: white; }
.nav-item.active { background: rgba(0,191,255,0.2); color: var(--primary); }

.nav-subitem {
  display: block;
  padding: 6px 16px 6px 28px;
  font-size: 13px;
  color: var(--sidebar-text-light);
  text-decoration: none;
  border-radius: 6px;
  margin: 1px 8px;
  transition: all 0.15s;
  cursor: pointer;
}
.nav-subitem:hover { background: var(--sidebar-hover-bg); color: var(--sidebar-text); }
.nav-subitem.active {
  background: rgba(0,191,255,0.1);
  color: var(--primary);
  border-left: 3px solid var(--primary);
  font-weight: 500;
  padding-left: 25px;
}

.sidebar-dark-footer { padding: 12px 16px; border-top: 1px solid var(--sidebar-border); }

/* ─── SIDEBAR (base partagée doc + admin) ─── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  color: white;
}

/* ─── SIDEBAR HEADER (logo + theme toggle) ─── */
.sidebar-header {
  padding: 24px 20px 16px;
  border-bottom: 1px solid var(--sidebar-border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-header img { height: 28px; width: auto; max-width: 180px; }

/* ─── SIDEBAR SECTION (titre + action dans la sidebar sombre) ─── */
.sidebar-section {
  padding: 12px 16px;
  border-bottom: 1px solid var(--sidebar-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.sidebar-section h3 {
  font-size: 13px; font-weight: 600;
  color: var(--sidebar-text-light);
  text-transform: uppercase; letter-spacing: 0.05em;
}

/* ─── SIDEBAR NAV (liste scrollable dans la sidebar sombre) ─── */
.sidebar-nav-dark { flex: 1; overflow-y: auto; padding: 8px 0; }

/* ─── SIDEBAR FOOTER ─── */
.sidebar-footer { padding: 12px 16px; border-top: 1px solid var(--sidebar-border); }

/* Search dans la sidebar */
.sidebar-search { padding: 12px 16px; }
.sidebar-search input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  border: 1px solid var(--sidebar-border);
  border-radius: 8px;
  font-size: 14px;
  background: var(--sidebar-input-bg);
  color: var(--sidebar-text);
  outline: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 10px center;
}
.sidebar-search input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(0,191,255,0.15); }

/* ─── BOUTON ICON (dans sidebar sombre) ─── */
.btn-icon {
  background: rgba(255,255,255,0.1); border: none; color: white;
  width: 28px; height: 28px; border-radius: 6px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; font-size: 16px;
  transition: background 0.15s;
}
.btn-icon:hover { background: rgba(255,255,255,0.2); }

/* ─── THEME TOGGLE ─── */
.theme-toggle {
  background: none;
  border: 1px solid var(--sidebar-border);
  border-radius: 8px;
  cursor: pointer;
  padding: 5px 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--sidebar-text);
  transition: color 0.2s, border-color 0.2s;
  flex-shrink: 0;
}
.theme-toggle:hover { color: white; border-color: rgba(255,255,255,0.5); }
.theme-toggle svg { width: 15px; height: 15px; }
.icon-sun, .icon-moon { display: none; }
[data-theme="dark"] .icon-sun  { display: block; }
[data-theme="dark"] .icon-moon { display: none; }
:not([data-theme="dark"]) .icon-sun  { display: none; }
:not([data-theme="dark"]) .icon-moon { display: block; }

/* ─── MOBILE HEADER SOMBRE ─── */
.mobile-header-dark {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 52px;
  background: #1a1f27;
  padding: 0 16px;
  z-index: 500;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  align-items: center;
  justify-content: space-between;
}
.mobile-header-dark img {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  height: 22px; width: auto;
}
.hamburger-dark {
  background: none; border: none; cursor: pointer;
  padding: 4px; display: flex; flex-direction: column; gap: 5px; flex-shrink: 0;
}
.hamburger-dark span { display: block; width: 22px; height: 2px; background: rgba(255,255,255,0.85); border-radius: 2px; }

/* ─── OVERLAY ─── */
.overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 95; cursor: pointer; }
.overlay.visible { display: block; }

/* ─── TOAST BANDEAU ─── */
.toast {
  position: fixed; top: 0; left: 0; right: 0;
  padding: 13px 20px;
  font-size: 14px; font-weight: 600; text-align: center;
  opacity: 0; transform: translateY(-100%); transition: all 0.3s ease;
  pointer-events: none; z-index: 9999; color: white;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { background: #16a34a; }
.toast.error   { background: #dc2626; }
.toast.info    { background: #2563eb; }

/* ─── BOUTON LOGOUT ─── */
.btn-logout {
  width: 100%; padding: 8px; background: none; border: 1px solid rgba(255,255,255,0.2);
  color: rgba(255,255,255,0.6); border-radius: 6px; font-size: 12px; cursor: pointer; transition: all 0.15s;
}
.btn-logout:hover { border-color: rgba(255,255,255,0.4); color: white; }

/* ─── INPUTS ─── */
.form-group { display: flex; flex-direction: column; gap: 5px; flex: 1; }
.form-group label { font-size: 12px; font-weight: 600; color: var(--text-light); text-transform: uppercase; letter-spacing: 0.04em; }
.form-group input[type=text], .form-group textarea, .form-group select {
  padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 14px; outline: none; transition: border-color 0.15s;
  background: var(--input-bg); color: var(--text);
}
.form-group input:focus, .form-group textarea:focus, .form-group select:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(0,191,255,0.12);
}

/* ─── MODAL ─── */
.modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  z-index: 1000; align-items: center; justify-content: center;
}
.modal-overlay.visible { display: flex; }
.modal {
  background: var(--modal-bg); border-radius: 12px; padding: 24px; width: 480px;
  max-height: 80vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.modal h2 { font-size: 1.1rem; font-weight: 700; color: var(--dark); margin-bottom: 16px; }
.modal-close { float: right; background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text-light); }
