/* ====================================================
   GRIMOIRE — Design System
   Dark, Netflix-inspired
   ==================================================== */

:root {
  --bg-base:        #141414;
  --bg-surface:     #1f1f1f;
  --bg-card:        #262626;
  --bg-hover:       #303030;
  --bg-input:       #2a2a2a;
  --accent:         #e8b84b;        /* Or/ambre — couleur signature */
  --accent-hover:   #f5cd6e;
  --accent-dim:     rgba(232,184,75,0.15);
  --danger:         #e05252;
  --success:        #52c878;
  --warning:        #e8b84b;
  --info:           #5295e0;
  --text-primary:   #e5e5e5;
  --text-secondary: #aaaaaa;
  --text-muted:     #666666;
  --border:         #333333;
  --border-accent:  rgba(232,184,75,0.4);
  --shadow:         0 4px 20px rgba(0,0,0,0.5);
  --shadow-card:    0 2px 8px rgba(0,0,0,0.4);
  --radius:         8px;
  --radius-lg:      12px;
  --radius-pill:    999px;
  --font:           'Inter', system-ui, -apple-system, sans-serif;
  --transition:     0.2s ease;

  /* Sensibilité */
  --sens-normal:       #52c878;
  --sens-confidentiel: #e8a84b;
  --sens-medical:      #e05252;
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
}

/* ── Scrollbar ───────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: #444; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #666; }

/* ── Typography ──────────────────────────────────── */
h1, h2, h3, h4 { font-weight: 600; line-height: 1.2; }
h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.1rem; }
a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-hover); }

/* ── Layout ──────────────────────────────────────── */
.app-wrapper {
  display: grid;
  grid-template-columns: 260px 1fr;
  grid-template-rows: auto 1fr;
  min-height: 100vh;
}

/* ── Navbar ──────────────────────────────────────── */
.navbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0 2rem;
  height: 64px;
  background: rgba(20,20,20,0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.navbar-brand {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.navbar-brand svg { width: 28px; height: 28px; }

.navbar-search {
  flex: 1;
  max-width: 480px;
  position: relative;
}
.navbar-search input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 0.5rem 1rem 0.5rem 2.5rem;
  color: var(--text-primary);
  font-size: 0.9rem;
  transition: border-color var(--transition);
}
.navbar-search input:focus { outline: none; border-color: var(--accent); }
.navbar-search .search-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.navbar-actions { margin-left: auto; display: flex; align-items: center; gap: 1rem; }

.avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--accent-dim);
  border: 2px solid var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--accent);
  cursor: pointer;
}

/* ── Sidebar ──────────────────────────────────────── */
.sidebar {
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  padding: 1.5rem 0;
  overflow-y: auto;
  position: sticky;
  top: 64px;
  height: calc(100vh - 64px);
}

.sidebar-section { margin-bottom: 2rem; }

.sidebar-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  padding: 0 1.25rem;
  margin-bottom: 0.5rem;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1.25rem;
  color: var(--text-secondary);
  font-size: 0.9rem;
  transition: all var(--transition);
  border-left: 3px solid transparent;
}
.sidebar-link:hover { color: var(--text-primary); background: var(--bg-hover); }
.sidebar-link.active { color: var(--accent); border-left-color: var(--accent); background: var(--accent-dim); }
.sidebar-link svg { width: 18px; height: 18px; flex-shrink: 0; }

.sidebar-count {
  margin-left: auto;
  font-size: 0.75rem;
  background: var(--bg-hover);
  color: var(--text-muted);
  padding: 0.1rem 0.5rem;
  border-radius: var(--radius-pill);
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  font-weight: 500;
  background: var(--bg-hover);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all var(--transition);
}
.tag-chip:hover { border-color: var(--accent); color: var(--accent); }
.tag-chip.active { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }

/* ── Main content ─────────────────────────────────── */
.main {
  padding: 2rem;
  overflow-y: auto;
  min-width: 0;
}

/* ── Section title (Netflix "bandes") ─────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.section-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
}
.section-link {
  font-size: 0.85rem;
  color: var(--accent);
}

/* ── Document Cards ───────────────────────────────── */
.doc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

.doc-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
  position: relative;
}
.doc-card:hover {
  transform: translateY(-4px) scale(1.01);
  box-shadow: var(--shadow);
  border-color: var(--border-accent);
}

.doc-card-thumb {
  aspect-ratio: 4/3;
  background: var(--bg-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}
.doc-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.doc-card-thumb .file-icon {
  font-size: 3rem;
  opacity: 0.4;
}

.doc-card-body { padding: 0.75rem; }
.doc-card-title {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 0.25rem;
}
.doc-card-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sensitivity-badge {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 10px; height: 10px;
  border-radius: 50%;
}
.sensitivity-badge.normal       { background: var(--sens-normal); }
.sensitivity-badge.confidentiel { background: var(--sens-confidentiel); }
.sensitivity-badge.médical      { background: var(--sens-medical); }

.doc-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: 0.5rem;
}
.doc-tag-mini {
  font-size: 0.65rem;
  padding: 0.1rem 0.4rem;
  border-radius: var(--radius-pill);
  background: var(--accent-dim);
  color: var(--accent);
}

/* ── Buttons ──────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1.25rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}
.btn-primary   { background: var(--accent); color: #0a0a0a; }
.btn-primary:hover { background: var(--accent-hover); color: #0a0a0a; }
.btn-secondary { background: var(--bg-card); color: var(--text-primary); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: 0.85; }
.btn-ghost     { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { color: var(--text-primary); background: var(--bg-hover); }
.btn-sm { padding: 0.35rem 0.8rem; font-size: 0.8rem; }
.btn-icon { padding: 0.5rem; border-radius: var(--radius); }

/* ── Forms ────────────────────────────────────────── */
.form-group { margin-bottom: 1.25rem; }
.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}
.form-control {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.6rem 0.9rem;
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: var(--font);
  transition: border-color var(--transition);
  -webkit-appearance: none;
}
.form-control:focus { outline: none; border-color: var(--accent); }
.form-control::placeholder { color: var(--text-muted); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 100px; }

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

/* ── Upload zone ──────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 3rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  background: var(--bg-surface);
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-dim);
}
.upload-zone input[type=file] { display: none; }
.upload-zone-icon { font-size: 3rem; margin-bottom: 1rem; opacity: 0.6; }
.upload-zone-text { color: var(--text-secondary); }
.upload-zone-text strong { color: var(--accent); }

/* ── Alerts ───────────────────────────────────────── */
.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.alert-error   { background: rgba(224,82,82,0.15); border: 1px solid rgba(224,82,82,0.3); color: #ff8080; }
.alert-success { background: rgba(82,200,120,0.15); border: 1px solid rgba(82,200,120,0.3); color: #80e8a0; }
.alert-warning { background: rgba(232,184,75,0.15); border: 1px solid rgba(232,184,75,0.3); color: var(--accent); }

/* ── Modal ────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}
.modal-backdrop.open { opacity: 1; pointer-events: all; }

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  max-width: 480px;
  width: 90%;
  box-shadow: var(--shadow);
  transform: scale(0.95);
  transition: transform var(--transition);
}
.modal-backdrop.open .modal { transform: scale(1); }

.modal-title { font-size: 1.1rem; font-weight: 600; margin-bottom: 1rem; }
.modal-warning {
  background: rgba(224,82,82,0.1);
  border: 1px solid rgba(224,82,82,0.3);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
  font-size: 0.88rem;
  line-height: 1.6;
  color: #ff9999;
}
.modal-actions { display: flex; gap: 0.75rem; justify-content: flex-end; margin-top: 1.5rem; }

/* ── Preview viewer ───────────────────────────────── */
.preview-container {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
}
.preview-container iframe,
.preview-container img {
  width: 100%;
  display: block;
  max-height: 75vh;
  object-fit: contain;
  background: #000;
}

/* ── Stats cards (admin) ──────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
}
.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 0.25rem;
}
.stat-label { font-size: 0.8rem; color: var(--text-muted); }

/* ── Table ────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
thead th {
  text-align: left;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
tbody td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
}
tbody tr:hover td { background: var(--bg-hover); }
tbody tr:last-child td { border-bottom: none; }

/* ── Pagination ───────────────────────────────────── */
.pagination {
  display: flex;
  gap: 0.25rem;
  justify-content: center;
  margin-top: 2rem;
}
.page-link {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius);
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 0.85rem;
  transition: all var(--transition);
}
.page-link:hover, .page-link.active { background: var(--accent); color: #0a0a0a; border-color: var(--accent); }

/* ── Breadcrumb ───────────────────────────────────── */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb-sep { opacity: 0.4; }

/* ── Collection cards ─────────────────────────────── */
.collection-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}
.collection-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  cursor: pointer;
  transition: all var(--transition);
}
.collection-card:hover { border-color: var(--border-accent); transform: translateY(-2px); box-shadow: var(--shadow-card); }
.collection-name { font-weight: 600; margin-bottom: 0.25rem; }
.collection-meta { font-size: 0.8rem; color: var(--text-muted); }

/* ── Progress bar (stockage) ──────────────────────── */
.storage-bar {
  height: 6px;
  border-radius: var(--radius-pill);
  background: var(--bg-hover);
  overflow: hidden;
  margin-top: 0.5rem;
}
.storage-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  background: var(--accent);
  transition: width 0.4s ease;
}
.storage-fill.warning { background: var(--warning); }
.storage-fill.danger  { background: var(--danger); }

/* ── Toasts ───────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.toast {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1.25rem;
  font-size: 0.88rem;
  box-shadow: var(--shadow);
  animation: slideIn 0.3s ease;
}
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: none; opacity: 1; } }

/* ── Responsive ───────────────────────────────────── */
@media (max-width: 900px) {
  .app-wrapper { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main { padding: 1rem; }
  .doc-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}
