:root {
  --sinamba-primary: #1d4ed8;
  --sinamba-primary-dark: #1e3a8a;
  --sinamba-bg: #f3f4f6;
  --sinamba-border: #e5e7eb;
  --sinamba-text: #1f2937;
  --sinamba-muted: #6b7280;
  --sinamba-danger: #dc2626;
  --sinamba-success: #16a34a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Segoe UI', Helvetica, Arial, sans-serif;
  background: var(--sinamba-bg);
  color: var(--sinamba-text);
}

a {
  color: var(--sinamba-primary);
}

/* Layout */
.admin-wrapper {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.admin-sidebar {
  width: 230px;
  flex-shrink: 0;
  background: var(--sinamba-primary-dark);
  color: #fff;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.admin-sidebar .brand {
  padding: 1.25rem 1rem;
  font-size: 1.1rem;
  font-weight: 700;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.admin-sidebar nav {
  flex: 1;
  padding: 1rem 0;
}

.admin-sidebar nav a {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.65rem 1.25rem;
  color: #e5e7eb;
  text-decoration: none;
  font-size: 0.95rem;
}

.admin-sidebar nav a:hover,
.admin-sidebar nav a.active {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.admin-sidebar form {
  padding: 1rem 1.25rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.admin-sidebar .logout-btn {
  width: 100%;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #fff;
  padding: 0.5rem;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

.admin-sidebar .logout-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.admin-main {
  flex: 1;
  height: 100vh;
  padding: 1.5rem 2rem;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: auto;
}

.admin-main h1 {
  margin-top: 0;
}

/* Coquille fixe : l'en-tête de chaque page (h1 ou .toolbar de premier niveau)
   reste visible pendant que le contenu défile dans .admin-main. */
.admin-main > h1:first-child,
.admin-main > .toolbar:first-child {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--sinamba-bg);
  padding-bottom: 1rem;
}

/* Apparence "app native" : la page occupe exactement la hauteur disponible
   (100vh moins le padding vertical de .admin-main) et ne défile jamais ;
   seul .panel-body (liste) défile en interne. */
.page-flex {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 3rem);
  min-height: 0;
}

.page-flex > h1:first-child,
.page-flex > .toolbar:first-child {
  flex-shrink: 0;
  position: static;
  padding-bottom: 0;
}

.page-flex .muted:has(+ .toolbar),
.page-flex > p:first-of-type {
  flex-shrink: 0;
}

/* Panneau de liste : en-tête fixe, corps scrollable. */
.panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 6px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  overflow: hidden;
}

.panel-header {
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--sinamba-border);
  gap: 1rem;
  flex-wrap: wrap;
}

.panel-header h2 {
  margin: 0;
  font-size: 1.05rem;
}

.panel-body {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.panel-body table.admin-table {
  box-shadow: none;
  border-radius: 0;
}

.panel-body table.admin-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
}

/* Grille 2 colonnes pour les formulaires (dialogues). */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

/* Dialogues modaux : en-tête et pied fixes, corps scrollable. */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 20;
  align-items: center;
  justify-content: center;
}

.modal-backdrop.open {
  display: flex;
}

.modal-card {
  background: #fff;
  border-radius: 8px;
  width: 100%;
  max-width: 560px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}

.modal-card.modal-wide {
  max-width: 920px;
}

.modal-header {
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--sinamba-border);
}

.modal-header h2 {
  margin: 0;
  font-size: 1.1rem;
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.5rem;
}

.modal-footer {
  flex-shrink: 0;
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--sinamba-border);
}

.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.25rem;
  color: var(--sinamba-muted);
  line-height: 1;
}

.modal-close:hover {
  color: var(--sinamba-text);
}

/* Icônes Material */
.material-symbols-outlined {
  font-size: 1.15rem;
  vertical-align: -3px;
  line-height: 1;
}

.btn .material-symbols-outlined {
  margin-right: 0.35rem;
}

/* Login page */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--sinamba-bg);
}

.login-card {
  background: #fff;
  padding: 2rem;
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
  width: 100%;
  max-width: 360px;
}

.login-card h1 {
  margin-top: 0;
  font-size: 1.4rem;
  text-align: center;
}

/* Forms */
.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.25rem;
  font-weight: 600;
  font-size: 0.9rem;
}

.form-control {
  width: 100%;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--sinamba-border);
  border-radius: 4px;
  font-size: 0.95rem;
}

.form-error {
  color: var(--sinamba-danger);
  font-size: 0.85rem;
  margin-top: 0.25rem;
}

.btn {
  display: inline-block;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  border: none;
  cursor: pointer;
  font-size: 0.95rem;
  text-decoration: none;
}

.btn-primary {
  background: var(--sinamba-primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--sinamba-primary-dark);
}

.btn-danger {
  background: var(--sinamba-danger);
  color: #fff;
}

.btn-secondary {
  background: #fff;
  border: 1px solid var(--sinamba-border);
  color: var(--sinamba-text);
}

.btn-block {
  width: 100%;
}

/* Tables */
table.admin-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

table.admin-table th,
table.admin-table td {
  padding: 0.6rem 0.85rem;
  border-bottom: 1px solid var(--sinamba-border);
  text-align: left;
  font-size: 0.9rem;
}

table.admin-table th {
  background: #f9fafb;
  font-weight: 600;
}

table.admin-table tr:last-child td {
  border-bottom: none;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.muted {
  color: var(--sinamba-muted);
}

.alert {
  padding: 0.65rem 1rem;
  border-radius: 4px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.alert-success {
  background: #dcfce7;
  color: #166534;
}

.badge-count {
  display: inline-block;
  min-width: 1.4rem;
  padding: 0.05rem 0.4rem;
  margin-left: 0.35rem;
  border-radius: 999px;
  background: var(--sinamba-danger);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 600;
  text-align: center;
  line-height: 1.3;
}

.alert-error {
  background: #fee2e2;
  color: #991b1b;
}
