/* ============================================================
   MAHUZIER ADMIN — admin.css
   Interface d'administration sobre, claire, efficace
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&display=swap');

:root {
  --bg:        #F4F6F9;
  --sidebar:   #1A1F2E;
  --sidebar-w: 240px;
  --white:     #ffffff;
  --border:    #E2E6EA;
  --primary:   #1A5276;
  --primary-h: #154360;
  --danger:    #C0392B;
  --success:   #1E8449;
  --warning:   #D68910;
  --gold:      #C9A84C;
  --text:      #1A1A2E;
  --muted:     #6C757D;
  --radius:    6px;
  --shadow:    0 2px 8px rgba(0,0,0,0.08);
  --transition: 0.2s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ────────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
}
#sidebar .sidebar-brand {
  padding: 1.4rem 1.4rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
#sidebar .sidebar-brand h1 {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--white);
  letter-spacing: 0.04em;
}
#sidebar .sidebar-brand p {
  font-size: 0.7rem;
  color: var(--gold);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-top: 2px;
}
#sidebar nav { flex: 1; padding: 1rem 0; }
#sidebar nav a {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.62rem 1.4rem;
  color: rgba(255,255,255,0.62);
  font-size: 0.85rem;
  font-weight: 400;
  text-decoration: none;
  transition: background var(--transition), color var(--transition);
  border-left: 3px solid transparent;
}
#sidebar nav a .icon { font-size: 1rem; width: 18px; text-align: center; }
#sidebar nav a:hover { background: rgba(255,255,255,0.07); color: rgba(255,255,255,0.9); }
#sidebar nav a.active { background: rgba(201,168,76,0.12); color: var(--gold); border-left-color: var(--gold); }
#sidebar nav .nav-section {
  padding: 0.9rem 1.4rem 0.3rem;
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: rgba(255,255,255,0.28);
}
#sidebar .sidebar-footer {
  padding: 1rem 1.4rem;
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 0.78rem;
  color: rgba(255,255,255,0.35);
}
#sidebar .sidebar-footer a { color: var(--danger); font-size: 0.78rem; text-decoration: none; }
#sidebar .sidebar-footer a:hover { color: #e74c3c; }

/* ── Main content ───────────────────────────────────────── */
#main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
#topbar {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}
#topbar h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}
#topbar .topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}
.content {
  padding: 2rem;
  flex: 1;
}

/* ── Cards / Panels ─────────────────────────────────────── */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-header {
  padding: 1rem 1.4rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-header h3 { font-size: 0.92rem; font-weight: 600; }
.card-body { padding: 1.4rem; }

/* ── Tables ─────────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.data-table th {
  text-align: left;
  padding: 0.65rem 1rem;
  background: var(--bg);
  color: var(--muted);
  font-weight: 500;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #F8F9FB; }
.data-table .thumb {
  width: 44px; height: 44px;
  object-fit: cover;
  border-radius: 4px;
  background: var(--bg);
}

/* ── Badges ─────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 0.72rem;
  font-weight: 500;
}
.badge-success { background: #d4edda; color: var(--success); }
.badge-danger  { background: #fde8e8; color: var(--danger); }
.badge-warning { background: #fef3cd; color: var(--warning); }
.badge-info    { background: #d0eaff; color: var(--primary); }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  font-size: 0.83rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: opacity var(--transition), background var(--transition);
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { opacity: 0.85; }
.btn-primary   { background: var(--primary); color: white; }
.btn-danger    { background: var(--danger); color: white; }
.btn-success   { background: var(--success); color: white; }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-sm { padding: 0.3rem 0.7rem; font-size: 0.78rem; }
.btn-icon { padding: 0.4rem; border-radius: 4px; background: transparent; border: 1px solid var(--border); color: var(--muted); }
.btn-icon:hover { background: var(--bg); color: var(--text); }

/* ── Forms ──────────────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; }
.form-grid .full { grid-column: 1 / -1; }
.form-group { display: flex; flex-direction: column; gap: 0.35rem; }
.form-group label { font-size: 0.8rem; font-weight: 500; color: var(--text); }
.form-group input,
.form-group textarea,
.form-group select {
  padding: 0.55rem 0.85rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-family: 'Inter', sans-serif;
  font-size: 0.88rem;
  color: var(--text);
  background: var(--white);
  outline: none;
  transition: border-color var(--transition);
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus { border-color: var(--primary); }
.form-group textarea { resize: vertical; min-height: 100px; }
.form-group .hint { font-size: 0.74rem; color: var(--muted); }

/* ── Modal ──────────────────────────────────────────────── */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 500;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--white);
  border-radius: 8px;
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.modal-header {
  padding: 1.2rem 1.4rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h3 { font-size: 1rem; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 1.4rem; cursor: pointer; color: var(--muted); padding: 0 4px; }
.modal-body { padding: 1.4rem; }
.modal-footer {
  padding: 1rem 1.4rem;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 0.6rem;
  justify-content: flex-end;
}

/* ── Stats dashboard ────────────────────────────────────── */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1.2rem;
  margin-bottom: 2rem;
}
.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 1.4rem;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 1rem;
}
.stat-card .sc-icon {
  width: 44px; height: 44px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}
.stat-card .sc-data h4 { font-size: 1.6rem; font-weight: 600; line-height: 1; }
.stat-card .sc-data p  { font-size: 0.75rem; color: var(--muted); margin-top: 3px; }

/* ── Alerts ─────────────────────────────────────────────── */
.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
  margin-bottom: 1rem;
  display: none;
}
.alert.show { display: block; }
.alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.alert-danger  { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }

/* ── Image list ─────────────────────────────────────────── */
.img-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.8rem;
  margin-top: 0.8rem;
}
.img-item {
  position: relative;
  aspect-ratio: 4/3;
  border-radius: 4px;
  overflow: hidden;
  background: var(--bg);
}
.img-item img { width: 100%; height: 100%; object-fit: cover; }
.img-item .img-del {
  position: absolute;
  top: 4px; right: 4px;
  background: var(--danger);
  color: white;
  border: none;
  border-radius: 50%;
  width: 22px; height: 22px;
  cursor: pointer;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity var(--transition);
}
.img-item:hover .img-del { opacity: 1; }

/* ── Login page ─────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--sidebar);
}
.login-box {
  background: var(--white);
  border-radius: 8px;
  padding: 2.4rem;
  width: 360px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}
.login-box h1 { font-size: 1.2rem; font-weight: 600; margin-bottom: 0.3rem; }
.login-box p  { font-size: 0.82rem; color: var(--muted); margin-bottom: 1.8rem; }

/* ── Toast ──────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.toast {
  padding: 0.8rem 1.2rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
  color: white;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  animation: toastIn 0.3s ease;
}
.toast.success { background: var(--success); }
.toast.error   { background: var(--danger); }
@keyframes toastIn { from { opacity:0; transform: translateY(10px); } to { opacity:1; transform: none; } }

@media (max-width: 768px) {
  #sidebar { transform: translateX(-100%); transition: transform 0.3s ease; }
  #sidebar.open { transform: none; }
  #main { margin-left: 0; }
  .form-grid { grid-template-columns: 1fr; }
}
