* { box-sizing: border-box; }
body {
  font-family: "Segoe UI", Arial, sans-serif;
  background: #f5f6f8;
  margin: 0;
  color: #1f2430;
}
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #1e293b;
  color: white;
  padding: 16px 28px;
  flex-wrap: wrap;
  gap: 10px;
}
.header-left { display: flex; align-items: center; gap: 12px; }
.dashboard-logo { height: 32px; width: auto; }
header h1 { margin: 0; font-size: 20px; }
header a { color: #93c5fd; text-decoration: none; }
header a:hover { text-decoration: underline; }
.user-info { font-size: 14px; }

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 28px 0;
  flex-wrap: wrap;
  gap: 12px;
}
.search-form { display: flex; gap: 8px; flex-wrap: wrap; }
.search-form input[type="text"] {
  padding: 8px 12px;
  width: 340px;
  max-width: 70vw;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 14px;
}
.search-form button {
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  background: #334155;
  color: white;
  cursor: pointer;
}
.clear-link { align-self: center; font-size: 13px; color: #666; text-decoration: none; margin-left: 4px; }
.clear-link:hover { text-decoration: underline; }

.btn-add {
  background: #2563eb;
  color: white;
  padding: 9px 16px;
  border-radius: 6px;
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
}
.btn-add:hover { background: #1d4ed8; }

.count-bar {
  margin: 14px 28px 0;
  font-size: 13px;
  color: #555;
  font-weight: 600;
}

.bulk-bar {
  display: none;
  align-items: center;
  gap: 12px;
  margin: 12px 28px 0;
  padding: 10px 16px;
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  border-radius: 8px;
  font-size: 13px;
  flex-wrap: wrap;
}
.bulk-bar input[type="text"] {
  padding: 7px 10px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 13px;
  flex: 1;
  min-width: 180px;
}
.bulk-bar button {
  padding: 7px 14px;
  border: none;
  border-radius: 6px;
  background: #2563eb;
  color: white;
  cursor: pointer;
  font-size: 13px;
  white-space: nowrap;
}
.bulk-bar button.danger { background: #dc2626; }

.table-wrap {
  margin: 12px 28px 20px;
  overflow-x: auto;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  background: white;
}
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}
th, td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid #eee;
  font-size: 14px;
  vertical-align: top;
}
th { background: #eef0f4; font-weight: 600; color: #333; white-space: nowrap; }
tr:hover { background: #fafbfc; }
.empty { text-align: center; color: #888; padding: 24px; }
.checkbox-col { width: 36px; text-align: center; }

.sort-link { color: #333; text-decoration: none; }
.sort-link:hover { color: #2563eb; }

a.connect { color: #2563eb; font-weight: 600; text-decoration: none; }
a.connect:hover { text-decoration: underline; }

.actions { white-space: nowrap; }
.actions a { color: #2563eb; text-decoration: none; margin-right: 12px; font-size: 13px; }
.actions a:hover { text-decoration: underline; }
.inline-form { display: inline; }
.link-btn {
  background: none;
  border: none;
  color: #dc2626;
  cursor: pointer;
  font-size: 13px;
  padding: 0;
  text-decoration: none;
  font-family: inherit;
}
.link-btn:hover { text-decoration: underline; }

.pagination {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 28px 30px;
  flex-wrap: wrap;
  font-size: 13px;
}
.pagination a {
  padding: 6px 11px;
  border: 1px solid #ddd;
  border-radius: 6px;
  text-decoration: none;
  color: #333;
  background: white;
}
.pagination a:hover { background: #eef0f4; }
.pagination a.active { background: #2563eb; color: white; border-color: #2563eb; }
.page-info { margin-left: 8px; color: #777; }

/* Formulaires (login + ajout/édition) */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 16px;
}
.login-box, .edit-form {
  background: white;
  padding: 32px;
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  width: 340px;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.edit-form { margin: 24px 28px; width: 480px; }
.login-logo { display: block; margin: 0 auto 12px; width: auto; height: auto; max-width: 100%; max-height: 140px; }
.login-box h1 { font-size: 18px; margin: 0 0 8px; text-align: center; }
label { font-size: 13px; font-weight: 600; color: #444; margin-top: 6px; }
input[type="text"], input[type="password"], textarea {
  padding: 9px 12px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 14px;
  width: 100%;
  font-family: inherit;
}
button[type="submit"] {
  margin-top: 12px;
  padding: 10px;
  border: none;
  border-radius: 6px;
  background: #2563eb;
  color: white;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
button[type="submit"]:hover { background: #1d4ed8; }

.error {
  background: #fee2e2;
  color: #b91c1c;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 13px;
}
.success {
  background: #dcfce7;
  color: #15803d;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 13px;
}

/* ============ RESPONSIVE ============ */
@media (max-width: 768px) {
  header { padding: 12px 16px; }
  .toolbar, .count-bar, .bulk-bar, .table-wrap, .pagination { margin-left: 16px; margin-right: 16px; }
  .search-form input[type="text"] { width: 100%; max-width: none; }
  .search-form { width: 100%; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .btn-add { text-align: center; }
  .edit-form { margin: 16px; width: auto; }
}

/* ============ ADMIN ============ */
.admin-content { margin: 24px 28px; max-width: 900px; }
.admin-content h2 { font-size: 16px; margin-top: 28px; }
.admin-content h3 { font-size: 14px; margin-top: 16px; color: #444; }
.hint { font-size: 12px; color: #777; }

.admin-menu {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  max-width: 900px;
}
.admin-card {
  background: white;
  border-radius: 8px;
  padding: 18px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  text-decoration: none;
  color: #1f2430;
  display: block;
}
.admin-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.15); }
.admin-card h3 { margin: 0 0 6px; font-size: 15px; color: #2563eb; }
.admin-card p { margin: 0; font-size: 13px; color: #666; }

.settings-form {
  background: white;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 500px;
  margin-bottom: 16px;
}
.settings-form label { font-size: 13px; font-weight: 600; color: #444; }
.settings-form select { padding: 8px; border: 1px solid #ccc; border-radius: 6px; font-size: 14px; }
.settings-form button { align-self: flex-start; margin-top: 8px; padding: 9px 16px; border: none; border-radius: 6px; background: #2563eb; color: white; cursor: pointer; font-weight: 600; }
.settings-form button.danger { background: #dc2626; }

.filter-form {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.filter-form input, .filter-form button {
  padding: 7px 10px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 13px;
}
.filter-form button { background: #334155; color: white; border: none; cursor: pointer; }

.export-bar { margin-bottom: 14px; display: flex; gap: 14px; font-size: 13px; }
.export-bar a { color: #2563eb; text-decoration: none; }
.export-bar a:hover { text-decoration: underline; }

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
}
.badge-success { background: #dcfce7; color: #15803d; }
.badge-danger  { background: #fee2e2; color: #b91c1c; }
.badge-create  { background: #dbeafe; color: #1d4ed8; }
.badge-update  { background: #fef3c7; color: #b45309; }
.badge-delete  { background: #fee2e2; color: #b91c1c; }

.history-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }
.history-entry {
  background: white;
  border-radius: 8px;
  padding: 10px 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  font-size: 13px;
}
.history-entry summary { cursor: pointer; }
.diff-table { width: 100%; margin-top: 10px; border-collapse: collapse; font-size: 12px; }
.diff-table th, .diff-table td { padding: 5px 8px; border-bottom: 1px solid #eee; text-align: left; }
.diff-old { color: #b91c1c; text-decoration: line-through; }
.diff-new { color: #15803d; font-weight: 600; }

details summary { list-style: revert; }

.column-order-list {
  background: white;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  padding: 8px 16px;
  max-width: 400px;
  margin-bottom: 16px;
}
.column-order-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid #eee;
  gap: 8px;
}
.column-order-row:last-child { border-bottom: none; }
.column-order-row .col-name { font-size: 13px; font-weight: 600; }
.column-order-row button {
  padding: 4px 10px;
  border: 1px solid #ccc;
  border-radius: 6px;
  background: white;
  cursor: pointer;
  font-size: 12px;
}
.column-order-row button:disabled { opacity: 0.3; cursor: not-allowed; }
