/* ==========================================================================
   ecollectdatabf — Thème Admin (Bootstrap 5)
   Palette et typographie pensées pour une plateforme de collecte de
   données terrain : sobre, lisible, avec un accent identifiable.
   ========================================================================== */

:root {
  /* Couleurs de marque */
  --brand-primary: #123c3a;       /* vert pin profond — confiance, structure */
  --brand-primary-dark: #0a2624;
  --brand-primary-light: #1c524f;
  --brand-accent: #c98a2e;        /* ocre chaud — accent, actions, focus */
  --brand-accent-light: #e6b567;

  /* Surfaces */
  --bg-app: #f5f3ee;
  --surface: #ffffff;
  --surface-sunken: #f0eee7;
  --border-color: #e4e1d8;

  /* Texte */
  --text-primary: #1a2421;
  --text-secondary: #52605c;
  --text-muted: #8a938e;
  --text-on-dark: #eef2f0;
  --text-on-dark-muted: #a9b8b3;

  /* États */
  --state-success: #2f8f5b;
  --state-success-bg: #e8f5ee;
  --state-warning: #e0a426;
  --state-warning-bg: #fbf1de;
  --state-danger: #c0392b;
  --state-danger-bg: #fbeae8;
  --state-info: #2f6f8f;
  --state-info-bg: #e8f1f5;

  /* Typographie */
  --font-display: "Plus Jakarta Sans", sans-serif;
  --font-body: "Inter", sans-serif;
  --font-mono: "JetBrains Mono", monospace;

  --sidebar-width: 260px;
  --topbar-height: 64px;
}

* { box-sizing: border-box; }

body {
  font-family: var(--font-body);
  background-color: var(--bg-app);
  color: var(--text-primary);
  font-size: 0.9375rem;
}

h1, h2, h3, h4, h5, h6, .font-display {
  font-family: var(--font-display);
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

a { text-decoration: none; }

/* ---------- Layout général ---------- */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.app-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

@media (max-width: 991.98px) {
  .app-content { margin-left: 0; }
}

/* ---------- Sidebar ---------- */
.app-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: linear-gradient(180deg, var(--brand-primary-dark) 0%, var(--brand-primary) 100%);
  color: var(--text-on-dark);
  display: flex;
  flex-direction: column;
  z-index: 1030;
  transition: transform 0.25s ease;
}

@media (max-width: 991.98px) {
  .app-sidebar {
    transform: translateX(-100%);
  }
  .app-sidebar.show {
    transform: translateX(0);
  }
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--brand-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--brand-primary-dark);
  font-size: 0.95rem;
  flex-shrink: 0;
}

.sidebar-brand-text {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.1;
  color: #fff;
}

.sidebar-brand-sub {
  font-size: 0.6875rem;
  color: var(--text-on-dark-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0.75rem;
}

.sidebar-section-label {
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-on-dark-muted);
  padding: 0.75rem 0.75rem 0.35rem;
  font-weight: 600;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  color: var(--text-on-dark-muted);
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.15rem;
  position: relative;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.sidebar-link i {
  font-size: 1.05rem;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-link:hover {
  background-color: rgba(255,255,255,0.06);
  color: #fff;
}

.sidebar-link.active {
  background-color: rgba(201,138,46,0.16);
  color: #fff;
}

.sidebar-link.active::before {
  content: "";
  position: absolute;
  left: -0.75rem;
  top: 0.35rem;
  bottom: 0.35rem;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--brand-accent);
}

.sidebar-link .badge-count {
  margin-left: auto;
  font-size: 0.6875rem;
  font-weight: 600;
  background: rgba(255,255,255,0.12);
  color: #fff;
  border-radius: 20px;
  padding: 0.1rem 0.5rem;
}

.sidebar-submenu {
  padding-left: 2.15rem;
}

.sidebar-submenu .sidebar-link {
  font-size: 0.8125rem;
  padding-top: 0.4rem;
  padding-bottom: 0.4rem;
}

.sidebar-toggle-caret {
  margin-left: auto;
  font-size: 0.75rem;
  transition: transform 0.2s ease;
}

.sidebar-link[aria-expanded="true"] .sidebar-toggle-caret {
  transform: rotate(90deg);
}

.sidebar-footer {
  padding: 0.9rem 1.25rem;
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 0.75rem;
  color: var(--text-on-dark-muted);
}

/* ---------- Topbar ---------- */
.app-topbar {
  height: var(--topbar-height);
  background: var(--surface);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 1020;
}

.topbar-title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0;
}

.topbar-breadcrumb {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.sidebar-burger {
  border: none;
  background: transparent;
  font-size: 1.25rem;
  color: var(--text-secondary);
  display: none;
}

@media (max-width: 991.98px) {
  .sidebar-burger { display: inline-flex; }
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
}

.topbar-user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--brand-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.8125rem;
}

.topbar-user-name {
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.1;
}

.topbar-user-role {
  font-size: 0.6875rem;
  color: var(--text-muted);
}

/* ---------- Zone de contenu ---------- */
.app-main {
  padding: 1.75rem;
  flex: 1;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.page-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.5rem;
  margin-bottom: 0.2rem;
}

.page-subtitle {
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* ---------- Cartes & stats ---------- */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.stat-value {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.4rem;
  line-height: 1.1;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.stat-section-label {
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 0.15rem;
}

.stat-card-link {
  text-decoration: none;
  color: inherit;
  transition: background-color 0.15s, border-color 0.15s;
}

.stat-card-link:hover {
  background: var(--surface-sunken);
  border-color: var(--brand-primary, var(--border-color));
}

.card-panel {
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: 12px;
}

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

.card-panel-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  margin: 0;
}

/* ---------- Tables ---------- */
.table-app {
  margin-bottom: 0;
}

.table-app thead th {
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border-color);
  padding: 0.85rem 1.25rem;
  background: var(--surface-sunken);
}

.table-app tbody td {
  padding: 0.85rem 1.25rem;
  vertical-align: middle;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.875rem;
}

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

.code-chip {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  background: var(--surface-sunken);
  border: 1px solid var(--border-color);
  padding: 0.15rem 0.5rem;
  border-radius: 6px;
  color: var(--text-secondary);
}

.avatar-sm {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--brand-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.7rem;
}

/* ---------- Badges de statut ---------- */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.65rem;
  border-radius: 20px;
}

.status-pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.status-success { background: var(--state-success-bg); color: var(--state-success); }
.status-warning { background: var(--state-warning-bg); color: var(--state-warning); }
.status-danger  { background: var(--state-danger-bg);  color: var(--state-danger); }
.status-info    { background: var(--state-info-bg);    color: var(--state-info); }
.status-muted   { background: var(--surface-sunken);   color: var(--text-muted); }

/* ---------- Boutons ---------- */
.btn-brand {
  background-color: var(--brand-primary);
  border-color: var(--brand-primary);
  color: #fff;
  font-weight: 600;
  font-size: 0.875rem;
}

.btn-brand:hover {
  background-color: var(--brand-primary-light);
  border-color: var(--brand-primary-light);
  color: #fff;
}

.btn-accent {
  background-color: var(--brand-accent);
  border-color: var(--brand-accent);
  color: #2a1c05;
  font-weight: 600;
  font-size: 0.875rem;
}

.btn-accent:hover {
  background-color: var(--brand-accent-light);
  border-color: var(--brand-accent-light);
  color: #2a1c05;
}

.btn-outline-app {
  border-color: var(--border-color);
  color: var(--text-secondary);
  font-size: 0.875rem;
  background: var(--surface);
}

.btn-outline-app:hover {
  background: var(--surface-sunken);
  color: var(--text-primary);
}

/* ---------- Empty state ---------- */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-muted);
}

.empty-state i {
  font-size: 2.25rem;
  color: var(--border-color);
  margin-bottom: 0.75rem;
  display: block;
}

/* ---------- Cloche de notifications ---------- */
.notification-bell-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 20px;
  background: var(--state-danger);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  border: 2px solid var(--surface);
}

.notification-dropdown {
  width: 360px;
  max-width: calc(100vw - 2rem);
  max-height: 420px;
  overflow-y: auto;
  padding: 0;
}

.notification-list {
  max-height: 340px;
  overflow-y: auto;
}

.notification-item {
  padding: 0.65rem 1rem;
  white-space: normal;
  border-bottom: 1px solid var(--border-color);
}

.notification-item:last-child {
  border-bottom: none;
}

.notification-item-unread {
  background: var(--surface-sunken);
}

.notification-time {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.notification-icon {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-sunken);
  color: var(--text-muted);
}

.notification-icon-new_response    { background: var(--state-info-bg);    color: var(--state-info); }
.notification-icon-status_changed  { background: var(--state-success-bg); color: var(--state-success); }
.notification-icon-anomaly         { background: var(--state-danger-bg);  color: var(--state-danger); }
.notification-icon-form_expiring   { background: var(--state-warning-bg); color: var(--state-warning); }

/* ---------- Focus visible (accessibilité) ---------- */
a:focus-visible, button:focus-visible, input:focus-visible, .sidebar-link:focus-visible {
  outline: 2px solid var(--brand-accent);
  outline-offset: 2px;
}

/* ---------- Modal de détail des réponses (large) ---------- */
/* Les réponses contiennent souvent des tableaux imbriqués (matrices, panneaux
   dynamiques) : on donne au modal toute la largeur utile de l'écran. */
.modal-response-detail {
  max-width: min(1400px, 96vw);
}

/* Colonne des libellés plus étroite pour laisser de la place aux valeurs. */
@media (min-width: 992px) {
  .modal-response-detail .modal-body > dl.row > dt {
    flex: 0 0 auto;
    width: 25%;
    max-width: 25%;
  }
  .modal-response-detail .modal-body > dl.row > dd {
    flex: 0 0 auto;
    width: 75%;
    max-width: 75%;
  }
}
