/* ===== Fonts ===== */
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600&display=swap');

/* ===== Theme tokens ===== */
:root,
[data-theme="light"] {
  --bg: #FBFBFB;
  --accent-selected: #DDDDE0;
  --primary: #FFFFFF;
  --secondary: #F3F3F4;
  --text: #27272B;
  --text-muted: #6B6B72;
  --border: #E4E4E7;
  --danger: #C0392B;
  --danger-bg: #FBEAE8;
  --success: #2E7D52;
  --success-bg: #E9F6EF;
  --shadow-bar: 0 8px 30px rgba(39, 39, 43, 0.08), 0 1px 2px rgba(39, 39, 43, 0.04);
  --shadow-card: 0 1px 3px rgba(39, 39, 43, 0.06);
  --role-user: #5B6BC0;
  --role-family: #2E9E83;
  --role-admin: #C0392B;
}

[data-theme="dark"] {
  --bg: #1A1A1E;
  --accent-selected: #2C2C30;
  --primary: #242429;
  --secondary: #121214;
  --text: #F1F1F1;
  --text-muted: #9B9BA3;
  --border: #313136;
  --danger: #E0685A;
  --danger-bg: #2E1A18;
  --success: #5FC596;
  --success-bg: #142A21;
  --shadow-bar: 0 8px 30px rgba(0, 0, 0, 0.35), 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.2);
  --role-user: #8C97DE;
  --role-family: #5FC596;
  --role-admin: #E0685A;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.2s ease, color 0.2s ease;
}

h1, h2, h3, .display {
  font-family: 'Space Grotesk', 'Inter', sans-serif;
  letter-spacing: -0.01em;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
}

::selection {
  background: var(--accent-selected);
}

/* ===== Layout ===== */
.page {
  min-height: 100vh;
  padding-top: 96px;
}

.page-content {
  max-width: 1100px;
  margin: 0 auto;
  padding: 40px 32px 80px;
}

/* ===== Navbar (barre deportee, centree, flottante) ===== */
.navbar {
  position: fixed;
  top: 12px;
  left: 12.5%;
  width: 75%;
  height: 64px;
  background: var(--primary);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-bar);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 1000;
}

.navbar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 17px;
  white-space: nowrap;
}

.navbar-logo img {
  height: 28px;
  width: 28px;
  border-radius: 7px;
  object-fit: cover;
  display: block;
}

.navbar-menu {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 4px;
  height: 100%;
}

.nav-item {
  position: relative;
  height: 100%;
  display: flex;
  align-items: center;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 38px;
  padding: 0 16px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  border: none;
  background: transparent;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.nav-link:hover {
  color: var(--text);
  background: var(--secondary);
}

.nav-link.active {
  color: var(--text);
  position: relative;
}

.nav-link.active::after {
  content: '';
  position: absolute;
  bottom: 1px;
  left: 16px;
  right: 16px;
  height: 2px;
  border-radius: 2px;
  background: var(--text);
}

.nav-chevron {
  width: 10px;
  height: 10px;
  transition: transform 0.15s ease;
}

.nav-item.open .nav-chevron {
  transform: rotate(180deg);
}

.nav-item.open .nav-link {
  background: var(--secondary);
  color: var(--text);
}

/* Sous-menu */
.submenu {
  position: absolute;
  top: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  min-width: 240px;
  background: var(--primary);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-bar);
  padding: 6px;
  display: none;
  flex-direction: column;
  gap: 2px;
}

.nav-item.open .submenu {
  display: flex;
}

.submenu-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

.submenu-link:hover {
  background: var(--secondary);
}

.submenu-link .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
}

/* ===== User menu ===== */
.user-menu-wrap {
  position: relative;
}

.user-avatar-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: var(--text);
  color: var(--bg);
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

.user-avatar-btn img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.user-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 230px;
  background: var(--primary);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-bar);
  padding: 8px;
  display: none;
  flex-direction: column;
  gap: 2px;
}

.user-menu-wrap.open .user-dropdown {
  display: flex;
}

.user-dropdown-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 10px;
}

.user-dropdown-header .role-pill {
  text-transform: capitalize;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  color: var(--text);
}

.dropdown-item:hover {
  background: var(--secondary);
}

.dropdown-item.danger {
  color: var(--danger);
}

.dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 6px 2px;
}

.theme-switch {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--secondary);
  border-radius: 10px;
  margin: 4px 2px 8px;
}

.theme-switch-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 7px 0;
  border-radius: 7px;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--text-muted);
}

.theme-switch-btn.active {
  background: var(--primary);
  color: var(--text);
  box-shadow: var(--shadow-card);
}

.theme-switch-btn svg {
  width: 16px;
  height: 16px;
}

/* ===== Cards generiques ===== */
.card {
  background: var(--primary);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-card);
}

.section-eyebrow {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

/* ===== Boutons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: opacity 0.15s ease, background-color 0.15s ease;
}

.btn-primary {
  background: var(--text);
  color: var(--bg);
}

.btn-primary:hover {
  opacity: 0.85;
}

.btn-secondary {
  background: var(--secondary);
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover {
  background: var(--accent-selected);
}

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
}

.btn-danger:hover {
  opacity: 0.85;
}

.btn-block {
  width: 100%;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ===== Forms ===== */
.field {
  margin-bottom: 18px;
}

.field label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 8px;
  color: var(--text);
}

.field input,
.field select {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--secondary);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
}

.field input:focus,
.field select:focus {
  outline: 2px solid var(--text);
  outline-offset: 1px;
}

/* ===== Role pill ===== */
.role-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 600;
  background: var(--secondary);
}

.role-pill::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.role-pill.role-user::before { background: var(--role-user); }
.role-pill.role-family::before { background: var(--role-family); }
.role-pill.role-admin::before { background: var(--role-admin); }

/* ===== Alerts ===== */
.alert {
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 20px;
}

.alert-error {
  background: var(--danger-bg);
  color: var(--danger);
}

.alert-success {
  background: var(--success-bg);
  color: var(--success);
}

/* ===== Table ===== */
table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  text-align: left;
  padding: 14px 16px;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
}

th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

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

td select {
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--secondary);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
}

/* ===== Visually hidden (focus accessible) ===== */
:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

/* ===== Responsive ===== */
@media (max-width: 860px) {
  .navbar {
    left: 12px;
    width: calc(100% - 24px);
    padding: 0 12px;
  }

  .navbar-menu {
    position: static;
    transform: none;
    gap: 0;
  }

  .navbar-logo span {
    display: none;
  }

  .page-content {
    padding: 28px 16px 60px;
  }
}
