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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f4f3f1;
  color: #222;
}

/* ---- Login ---- */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.login-card {
  background: white;
  padding: 32px;
  border-radius: 14px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  width: 100%;
  max-width: 340px;
}

.login-card h1 {
  font-size: 20px;
  margin-bottom: 20px;
  text-align: center;
}

.login-card input {
  width: 100%;
  padding: 12px;
  margin-bottom: 12px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 15px;
}

.error-msg {
  color: #b23a3a;
  font-size: 14px;
  margin-top: 8px;
  text-align: center;
}

/* ---- Topbar ---- */
.topbar {
  background: #2d2a26;
  color: white;
  padding: 16px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
}

.topbar-nav {
  display: flex;
  gap: 18px;
  flex: 1;
}

.topbar-nav a {
  color: #ccc;
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  padding: 4px 0;
  border-bottom: 2px solid transparent;
}

.topbar-nav a:hover {
  color: white;
}

.topbar-nav a.active {
  color: white;
  border-bottom-color: #3a7d44;
}

.topbar-title {
  font-size: 18px;
  font-weight: 600;
}

.logout-link {
  color: #ccc;
  text-decoration: none;
  font-size: 14px;
}

.logout-link:hover {
  color: white;
}

/* ---- Layout ---- */
.admin-main {
  padding: 24px;
  max-width: 1200px;
  margin: 0 auto;
}

/* ---- Filtres ---- */
.filters {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.quick-filters {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.quick-pill {
  padding: 8px 16px;
  border-radius: 20px;
  background: white;
  border: 1px solid #ddd;
  color: #555;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
}

.quick-pill.active {
  background: #2d2a26;
  border-color: #2d2a26;
  color: white;
}

.filters input, .filters select {
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 14px;
}

.btn-primary {
  background: #3a7d44;
  color: white;
  border: none;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary.full { width: 100%; padding: 14px; }

.btn-secondary {
  background: #e5e3df;
  color: #333;
  border: none;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
}

.btn-secondary-link {
  display: inline-flex;
  align-items: center;
  color: #666;
  font-size: 14px;
  text-decoration: none;
  padding: 10px 12px;
}

/* ---- Table ---- */
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.data-table th {
  background: #eceae6;
  text-align: left;
  padding: 12px 14px;
  font-size: 13px;
  font-weight: 600;
  color: #555;
}

.data-table th a {
  color: inherit;
  text-decoration: none;
}

.data-table td {
  padding: 10px 14px;
  border-top: 1px solid #f0efec;
  font-size: 14px;
}

.data-table td.editable, .data-table td.editable-select {
  cursor: pointer;
}

.data-table td.editable:hover, .data-table td.editable-select:hover {
  background: #f8f7f5;
}

.data-table td.saving {
  opacity: 0.5;
}

.data-table td.readonly {
  color: #666;
}

.inline-input {
  width: 100%;
  padding: 4px 6px;
  font-size: 14px;
  border: 1px solid #3a7d44;
  border-radius: 4px;
}

.checkbox-display {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid #ccc;
  border-radius: 5px;
  cursor: pointer;
}

.checkbox-display.checked {
  background: #3a7d44;
  border-color: #3a7d44;
}

.btn-delete {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 15px;
  opacity: 0.5;
}

.btn-delete:hover { opacity: 1; }

.cours-context {
  background: #eef6ef;
  border: 1px solid #3a7d44;
  color: #2d5233;
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
}

.toolbar-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.total-badge {
  margin-left: auto;
  font-size: 14px;
  color: #444;
}

.total-badge strong {
  color: #3a7d44;
  font-size: 16px;
}

.empty {
  text-align: center;
  color: #999;
  padding: 30px 0;
}

.hint-inline {
  font-size: 12px;
  color: #aaa;
  font-style: italic;
}

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

.badge-green { background: #eef6ef; color: #3a7d44; }
.badge-red { background: #fdf3e7; color: #b23a3a; }

.field-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #555;
  margin: 4px 0 6px;
}

.checkbox-list {
  max-height: 180px;
  overflow-y: auto;
  border: 1px solid #eee;
  border-radius: 8px;
  padding: 8px;
  margin-bottom: 14px;
}

.checkbox-list-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 4px;
  font-size: 14px;
}

.checkbox-list-item input { width: auto; margin: 0; }

/* ---- Modale ---- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.hidden { display: none !important; }

.modal-content {
  background: white;
  border-radius: 14px;
  padding: 24px;
  width: 100%;
  max-width: 380px;
}

.modal-content h2 {
  margin-bottom: 16px;
  font-size: 18px;
}

.modal-content input, .modal-content select {
  width: 100%;
  padding: 12px;
  font-size: 15px;
  border: 1px solid #ddd;
  border-radius: 8px;
  margin-bottom: 10px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  margin-bottom: 14px;
}

.checkbox-label input { width: auto; margin: 0; }

.modal-actions {
  display: flex;
  gap: 10px;
}

.modal-actions button {
  flex: 1;
  padding: 12px;
  border-radius: 8px;
  border: none;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

/* ---- Toast ---- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #2d2a26;
  color: white;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 200;
}

.logout-icon {
  display: none;
  font-size: 20px;
}

.toast.error {
  background: #b23a3a;
}

/* ---- Mobile : navigation qui passe à la ligne, tableaux défilables ---- */
@media (max-width: 768px) {
  .topbar {
    flex-wrap: wrap;
    gap: 10px 16px;
    padding: 14px 16px;
  }

  .topbar-title {
    flex: 1 1 auto;
    font-size: 16px;
    order: 1;
  }

  .logout-link {
    order: 2;
  }

  .logout-full {
    display: none;
  }

  .logout-icon {
    display: inline;
  }

  .topbar-nav {
    order: 3;
    flex-basis: 100%; /* force le passage à la ligne, sous le titre/déconnexion */
    flex-wrap: wrap;
    gap: 10px 16px;
    font-size: 13px;
  }

  .admin-main {
    padding: 14px;
  }

  .filters, .toolbar-row {
    flex-direction: column;
    align-items: stretch;
  }

  .total-badge {
    margin-left: 0;
  }

  /* Le tableau garde sa mise en page normale mais devient scrollable horizontalement
     plutôt que d'écraser les colonnes sur petit écran */
  .admin-main {
    overflow-x: auto;
  }

  .data-table {
    min-width: 640px;
  }
}
