/* YAM CYBER Admin — thème sombre + motif circuit */

:root {
  --bg-home: #0b100e;
  --bg: #141b18;
  --bg-elevated: #1a2320;
  --fg: #eef2ef;
  --muted: #9ca89f;
  --primary: #006e25;
  --primary-dark: #004d1a;
  --primary-light: #6fff82;
  --primary-muted: rgba(111, 255, 130, 0.1);
  --primary-border: rgba(111, 255, 130, 0.28);
  --secondary: #1f2824;
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.14);
  --danger: #f87171;
  --danger-bg: rgba(248, 113, 113, 0.12);
  --success-bg: rgba(0, 110, 37, 0.22);
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.35);
  --header-h: 52px;
  --nav-h: 56px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --app-max: 430px;
  --sidebar-w: 260px;
  --accent: #6fff82;
  --font-display: "Orbitron", system-ui, sans-serif;
  --font-body: "Roboto", system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  height: 100%;
  color-scheme: dark;
}

body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  color: var(--fg);
  background: var(--bg-home);
}

a {
  color: var(--primary-light);
  text-decoration: none;
}

img {
  max-width: 100%;
  display: block;
}

/* ─── Fond circuit sombre ─── */

.circuit-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-color: var(--bg-home);
  background-image:
    radial-gradient(ellipse 100% 60% at 50% 0%, rgba(0, 110, 37, 0.18), transparent 55%),
    radial-gradient(ellipse 80% 50% at 80% 100%, rgba(111, 255, 130, 0.05), transparent 50%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='160'%3E%3Cg fill='none' stroke='%236fff82' stroke-opacity='0.09' stroke-width='1'%3E%3Cpath d='M20 0v40M20 40h30M50 40v25M50 65h35M85 65v95'/%3E%3Cpath d='M60 0v20M60 20h40M100 20v140'/%3E%3Cpath d='M0 80h25M25 80v50M25 130h20'/%3E%3C/g%3E%3Ccircle cx='20' cy='40' r='2' fill='%236fff82' fill-opacity='0.14'/%3E%3Ccircle cx='50' cy='65' r='2' fill='%236fff82' fill-opacity='0.14'/%3E%3Ccircle cx='85' cy='65' r='2' fill='%236fff82' fill-opacity='0.14'/%3E%3Ccircle cx='60' cy='20' r='2' fill='%236fff82' fill-opacity='0.14'/%3E%3C/svg%3E");
  background-repeat: repeat;
}

/* ─── Shell ─── */

.app-shell {
  position: relative;
  max-width: var(--app-max);
  margin: 0 auto;
  min-height: 100dvh;
  overflow: hidden;
}

.app-frame {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.desktop-only {
  display: none !important;
}

.mobile-only {
  display: block;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  min-height: var(--header-h);
  padding: 10px 8px;
  background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 100%);
  border-bottom: 1px solid rgba(111, 255, 130, 0.2);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.header-side {
  width: 40px;
  flex-shrink: 0;
}

.header-back {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 24px;
  font-weight: 600;
  text-decoration: none;
  flex-shrink: 0;
}

.header-title {
  flex: 1;
  margin: 0;
  font-family: var(--font-body);
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  text-align: center;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-main {
  position: relative;
  z-index: 1;
  padding: 16px 16px calc(var(--nav-h) + var(--safe-bottom) + 20px);
}

/* ─── Bottom nav ─── */

.nav-root {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--app-max);
  z-index: 100;
}

.nav-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 90;
}

.nav-backdrop[hidden],
.more-panel[hidden] {
  display: none !important;
}

.bottom-nav {
  position: relative;
  z-index: 100;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border-strong);
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.45);
  padding-bottom: var(--safe-bottom);
}

.more-panel {
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
}

.more-link {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  color: var(--muted);
  font-size: 16px;
  font-weight: 500;
  text-decoration: none;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
}

.more-link:last-child {
  border-bottom: none;
}

.more-link svg {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

.more-link.active,
.more-link:active {
  color: var(--primary-light);
  background: var(--primary-muted);
}

.more-link-logout {
  color: var(--danger);
}

.nav-tabs {
  display: flex;
  align-items: stretch;
  justify-content: space-around;
  min-height: 52px;
  padding: 8px 4px 4px;
}

.nav-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 4px 2px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-body);
  cursor: pointer;
  text-decoration: none;
}

.nav-tab-icon svg {
  width: 26px;
  height: 26px;
}

.nav-tab-label {
  font-size: 10px;
  font-weight: 500;
  line-height: 1.2;
}

.nav-tab.active,
.nav-tab-plus.active {
  color: var(--primary-light);
}

.nav-tab.active .nav-tab-label,
.nav-tab-plus.active .nav-tab-label {
  font-weight: 600;
}

/* ─── Accueil ─── */

.welcome-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.welcome-logo {
  width: 44px;
  height: auto;
  border-radius: 6px;
  flex-shrink: 0;
  border: 1px solid var(--primary-border);
}

.welcome-text h2 {
  margin: 0;
  font-family: var(--font-body);
  font-size: 17px;
  font-weight: 700;
  color: var(--fg);
}

.welcome-text p {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.stat-card {
  background: linear-gradient(145deg, var(--primary) 0%, var(--primary-dark) 100%);
  border: 1px solid var(--primary-border);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-card);
}

.stat-card strong {
  display: block;
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 800;
  color: #fff;
  line-height: 1;
}

.stat-card span {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.85);
  line-height: 1.3;
}

/* ─── Cartes ─── */

.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 16px;
  margin-bottom: 12px;
}

.card-title {
  margin: 0 0 8px;
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 700;
  color: var(--fg);
}

.card-title-accent {
  color: var(--primary-light);
}

.section-heading {
  margin: 20px 0 12px;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
}

/* ─── Listes ─── */

.list-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.list-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  box-shadow: var(--shadow-card);
}

.list-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 4px;
}

.list-card-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--fg);
  line-height: 1.35;
}

.list-card-meta {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.4;
}

.list-card-meta + .list-card-meta {
  margin-top: 2px;
}

.list-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.list-card-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 3px 0;
  font-size: 14px;
  color: var(--fg);
}

.list-card-row .label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.phone-chip {
  display: inline-flex;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--primary-muted);
  border: 1px solid var(--primary-border);
  color: var(--primary-light);
  font-weight: 700;
  font-size: 14px;
  text-decoration: none;
}

.empty-state {
  text-align: center;
  padding: 36px 16px;
  color: var(--muted);
  font-size: 14px;
}

/* ─── Segmented ─── */

.segmented {
  display: flex;
  gap: 0;
  padding: 4px;
  margin-bottom: 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.segmented-btn {
  flex: 1;
  padding: 10px 8px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  color: var(--muted);
  text-decoration: none;
}

.segmented-btn.active {
  background: var(--primary);
  color: #fff;
}

/* ─── Boutons ─── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 20px;
  border: none;
  border-radius: 999px;
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.2;
}

.btn-block {
  width: 100%;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.btn-primary:active {
  background: var(--primary-dark);
  color: #fff;
}

.btn-ghost {
  background: var(--bg-elevated);
  color: var(--primary-light);
  border: 1px solid var(--border-strong);
}

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid rgba(248, 113, 113, 0.35);
}

.btn-sm {
  min-height: 36px;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 600;
}

/* ─── Formulaires ─── */

.form-grid {
  display: grid;
  gap: 16px;
}

.quiz-options {
  margin: 0;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  display: grid;
  gap: 14px;
}

.quiz-options legend {
  padding: 0 6px;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--accent);
  text-transform: uppercase;
}

.form-section {
  padding-top: 16px;
  margin-top: 4px;
  border-top: 1px solid var(--border);
}

.form-section:first-child {
  padding-top: 0;
  margin-top: 0;
  border-top: none;
}

.form-row {
  display: grid;
  gap: 16px;
}

.form-row-2 {
  grid-template-columns: 1fr 1fr;
}

.form-row-3 {
  grid-template-columns: 1fr 1fr 1fr;
}

@media (max-width: 380px) {
  .form-row-2,
  .form-row-3 {
    grid-template-columns: 1fr;
  }
}

label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--fg);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="number"],
input[type="file"],
textarea,
select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 16px;
  color: var(--fg);
  background: var(--bg-home);
  appearance: none;
}

textarea {
  min-height: 120px;
  resize: vertical;
}

input::placeholder,
textarea::placeholder {
  color: #6b7280;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-muted);
}

select option {
  background: var(--bg-elevated);
  color: var(--fg);
}

.photo-upload {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
}

.photo-preview {
  width: 110px;
  height: 110px;
  object-fit: cover;
  border-radius: var(--radius-lg);
  border: 2px solid var(--primary);
}

.page-toolbar {
  margin-bottom: 14px;
}

.page-toolbar .muted {
  margin: 0;
  font-size: 14px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.actions-sticky {
  padding-top: 8px;
}

.fab {
  position: fixed;
  right: max(16px, calc(50% - var(--app-max) / 2 + 16px));
  bottom: calc(var(--nav-h) + var(--safe-bottom) + 16px);
  z-index: 50;
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 26px;
  background: var(--primary);
  color: #fff;
  border: 1px solid var(--primary-border);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
  text-decoration: none;
}

.fab svg {
  width: 24px;
  height: 24px;
}

.fab:active {
  transform: scale(0.96);
  background: var(--primary-dark);
}

/* ─── Alertes & badges ─── */

.alert {
  padding: 12px 14px;
  margin-bottom: 12px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
}

.alert-error {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid rgba(248, 113, 113, 0.35);
}

.alert-success {
  background: var(--success-bg);
  color: var(--primary-light);
  border: 1px solid var(--primary-border);
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.badge-on {
  background: var(--primary-muted);
  color: var(--primary-light);
  border: 1px solid var(--primary-border);
}

.badge-off {
  background: var(--secondary);
  color: var(--muted);
  border: 1px solid var(--border);
}

.badge-urgent {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid rgba(248, 113, 113, 0.3);
}

.muted {
  color: var(--muted);
}

/* ─── Connexion ─── */

.auth-page {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: var(--bg-home);
  position: relative;
  overflow: hidden;
}

.auth-page .circuit-bg {
  position: fixed;
}

.auth-shell {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: var(--app-max);
}

.auth-card {
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-card);
  padding: 28px 22px;
}

.auth-brand {
  text-align: center;
  margin-bottom: 28px;
}

.auth-logo {
  width: 140px;
  height: auto;
  margin: 0 auto 14px;
  border-radius: 8px;
  border: 1px solid var(--primary-border);
}

.auth-brand h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--primary-light);
}

.auth-brand p {
  margin: 6px 0 0;
  font-size: 14px;
  color: var(--muted);
}

.auth-footer {
  margin-top: 18px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}

/* migrate / legacy */
.brand {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 20px;
}

.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.9rem;
}

.brand h1 {
  margin: 0;
  font-size: 1.1rem;
  color: var(--primary-light);
}

.brand p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.link-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.link-list li {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.link-list li:last-child {
  border-bottom: none;
}

.link-list a {
  color: var(--primary-light);
}

.code-list code {
  background: var(--secondary);
  color: var(--primary-light);
}

/* ─── Desktop (≥ 900px) ─── */

@media (min-width: 900px) {
  :root {
    --header-h: 64px;
  }

  body {
    font-size: 15px;
  }

  .desktop-only {
    display: flex !important;
  }

  .mobile-only,
  .nav-root.mobile-only {
    display: none !important;
  }

  .app-shell {
    max-width: none;
    margin: 0;
    min-height: 100dvh;
    overflow: visible;
    display: grid;
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  }

  .app-shell > .circuit-bg {
    position: fixed;
  }

  .app-frame {
    min-height: 100dvh;
    min-width: 0;
    display: flex;
    flex-direction: column;
  }

  /* Sidebar */
  .side-nav {
    position: sticky;
    top: 0;
    z-index: 30;
    height: 100dvh;
    flex-direction: column;
    background: rgba(15, 22, 19, 0.96);
    border-right: 1px solid var(--border-strong);
    backdrop-filter: blur(10px);
    padding: 20px 14px 16px;
    gap: 8px;
  }

  .side-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 8px 18px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 8px;
  }

  .side-logo {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    object-fit: cover;
    border: 1px solid var(--primary-border);
    flex-shrink: 0;
  }

  .side-brand-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
  }

  .side-brand-text strong {
    font-family: var(--font-display);
    font-size: 13px;
    letter-spacing: 0.04em;
    color: var(--primary-light);
  }

  .side-brand-text span {
    font-size: 12px;
    color: var(--muted);
  }

  .side-menu {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 4px 0;
  }

  .side-section-label {
    margin: 14px 10px 6px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
  }

  .side-section-label:first-child {
    margin-top: 4px;
  }

  .side-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 12px;
    border-radius: 12px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease;
  }

  .side-link-icon {
    display: flex;
    width: 22px;
    height: 22px;
    flex-shrink: 0;
  }

  .side-link-icon svg {
    width: 22px;
    height: 22px;
  }

  .side-link:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--fg);
  }

  .side-link.active {
    background: var(--primary-muted);
    color: var(--primary-light);
    box-shadow: inset 3px 0 0 var(--primary-light);
  }

  .side-footer {
    margin-top: auto;
    padding-top: 14px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  .side-user {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 0 10px;
  }

  .side-user strong {
    font-size: 13px;
    color: var(--fg);
  }

  .side-user span {
    font-size: 12px;
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .side-logout {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 12px;
    color: var(--danger);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
  }

  .side-logout svg {
    width: 20px;
    height: 20px;
  }

  .side-logout:hover {
    background: var(--danger-bg);
  }

  /* Header / content */
  .app-header {
    position: sticky;
    top: 0;
    padding: 0 28px;
    border-radius: 0;
  }

  .header-title {
    text-align: left;
    font-size: 20px;
  }

  .header-side {
    width: 0;
  }

  .header-back {
    margin-right: 8px;
  }

  .app-main {
    padding: 28px 32px 48px;
    max-width: 1120px;
  }

  /* Content density */
  .stats-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
  }

  .stat-card {
    padding: 20px;
  }

  .stat-card strong {
    font-size: 2rem;
  }

  .list-cards {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
  }

  .list-card {
    height: 100%;
  }

  .form-grid.card,
  .card {
    max-width: 760px;
  }

  .form-row-2 {
    grid-template-columns: 1fr 1fr;
  }

  .form-row-3 {
    grid-template-columns: 1fr 1fr 1fr;
  }

  .segmented {
    max-width: 520px;
  }

  .welcome-bar {
    margin-bottom: 24px;
  }

  .welcome-logo {
    width: 56px;
  }

  .welcome-text h2 {
    font-size: 22px;
  }

  .fab {
    right: 28px;
    bottom: 28px;
  }

  .actions:not(.actions-sticky) {
    justify-content: flex-start;
  }

  .btn-block {
    width: auto;
    min-width: 180px;
  }

  .actions-sticky .btn-block {
    width: auto;
  }

  .actions-sticky {
    display: flex;
    gap: 10px;
  }

  /* Login wider on desktop */
  .auth-shell {
    max-width: 440px;
  }

  .auth-card {
    padding: 36px 32px;
  }
}

@media (min-width: 1280px) {
  :root {
    --sidebar-w: 280px;
  }

  .app-main {
    padding: 32px 40px 56px;
    max-width: 1200px;
  }

  .stats-grid {
    gap: 18px;
  }
}

