/* ==========================================================================
   Waooh Streaming — feuille de style commune (index, login, admin)
   ========================================================================== */

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

:root {
  --bg: #0a0912;
  --surface: #13111f;
  --surface-2: #1a1729;
  --field: #1c1a2c;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #f3f2f9;
  --muted: #9d9ab3;
  --primary: #7c5cff;
  --primary-hover: #6a47f7;
  --primary-soft: rgba(124, 92, 255, 0.16);
  --success: #16a34a;
  --danger: #dc2626;
  --radius: 16px;
  --radius-field: 12px;
  --font: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

html {
  -webkit-text-size-adjust: 100%;
}

[hidden] {
  display: none !important;
}

body {
  font-family: var(--font);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
  padding: 32px 16px 56px;
  background-color: var(--bg);
  background-image:
    radial-gradient(60rem 28rem at 50% -8rem, rgba(124, 92, 255, 0.22), transparent 70%),
    radial-gradient(30rem 20rem at 100% 100%, rgba(124, 92, 255, 0.08), transparent 70%);
  background-repeat: no-repeat;
}

a {
  color: #b3a0ff;
}

.container {
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
}

.container-wide {
  max-width: 960px;
}

/* ---------- En-tête : logo + navigation ---------- */
.header {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 20px;
  margin-bottom: 28px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 13px;
  background: linear-gradient(145deg, #9b82ff, #6a47f7);
  box-shadow: 0 8px 24px rgba(124, 92, 255, 0.4);
}

.brand-mark svg {
  width: 18px;
  height: 18px;
  fill: #fff;
  margin-left: 2px;
}

.header h1 {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: var(--text);
}

.nav-links {
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
}

.nav-links a {
  text-decoration: none;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 8px 20px;
  border-radius: 999px;
  background: transparent;
  transition: color 0.2s ease, background-color 0.2s ease;
}

.nav-links a:hover {
  color: var(--text);
}

.nav-links a.active {
  color: #fff;
  background: var(--primary);
}

.nav-links a:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* ---------- Alertes ---------- */
.alert {
  display: none;
  padding: 14px 16px;
  border-radius: 12px;
  margin-bottom: 18px;
  font-size: 0.92rem;
  font-weight: 500;
  line-height: 1.45;
}

.alert.show {
  display: block;
}

.alert-error {
  background: rgba(220, 38, 38, 0.14);
  border: 1px solid rgba(220, 38, 38, 0.45);
  color: #fca5a5;
}

.alert-success {
  background: rgba(22, 163, 74, 0.14);
  border: 1px solid rgba(22, 163, 74, 0.45);
  color: #86efac;
}

.alert-info {
  background: rgba(37, 99, 235, 0.14);
  border: 1px solid rgba(37, 99, 235, 0.45);
  color: #93c5fd;
}

/* ---------- Carte ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 28px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

.card h2 {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin-bottom: 24px;
}

.card h2 + .card-sub {
  margin-top: -16px;
}

.card-sub {
  color: var(--muted);
  font-size: 0.92rem;
  margin-bottom: 24px;
}

.card-footer {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

.card-footer a {
  font-weight: 600;
  text-decoration: none;
}

.card-footer a:hover {
  text-decoration: underline;
}

.info-text {
  margin: -8px 0 24px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--primary-soft);
  border: 1px solid rgba(124, 92, 255, 0.3);
  color: #d4cbff;
  font-size: 0.9rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.info-text:empty {
  display: none;
}

/* ---------- Formulaires ---------- */
.form-group {
  margin-bottom: 22px;
}

.form-group label {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
}

.form-group input,
.country-btn {
  font-family: inherit;
  font-size: 1rem;
  height: 50px;
  border-radius: var(--radius-field);
  border: 1px solid var(--border-strong);
  background: var(--field);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-group input {
  width: 100%;
  padding: 0 16px;
}

.form-group input::placeholder {
  color: #77738f;
}

.form-group input:focus,
.country-btn:focus-visible,
.country-btn[aria-expanded="true"] {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.hint {
  display: block;
  margin-top: 8px;
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--muted);
}

/* Code de validation : grands chiffres espacés */
.form-group input.code-input {
  height: 64px;
  text-align: center;
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: 0.5em;
  padding-left: calc(16px + 0.5em);
  font-variant-numeric: tabular-nums;
}

.form-group input.code-input::placeholder {
  letter-spacing: 0.5em;
  font-weight: 500;
}

/* Mot de passe + bouton afficher */
.input-wrap {
  position: relative;
}

.input-wrap input {
  padding-right: 96px;
}

.toggle-pass {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  padding: 8px 12px;
  margin: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

.toggle-pass:hover {
  color: var(--text);
}

.toggle-pass:focus-visible {
  outline: 2px solid var(--primary);
}

/* ---------- Téléphone : indicatif + numéro ---------- */
.phone-field {
  position: relative;
  display: flex;
  align-items: stretch;
  gap: 10px;
}

.phone-field input[type="tel"] {
  flex: 1;
  min-width: 0;
  width: auto;
}

.country-btn {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 0 12px;
  font-weight: 600;
  cursor: pointer;
}

.country-btn .chev {
  width: 10px;
  height: 10px;
  flex: none;
  opacity: 0.6;
  transition: transform 0.2s ease;
}

.country-btn[aria-expanded="true"] .chev {
  transform: rotate(180deg);
}

.flag {
  display: block;
  width: 24px;
  height: 17px;
  flex: none;
  object-fit: cover;
  border-radius: 3px;
  background: #26233a;
}

.flag-fallback {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 17px;
  flex: none;
  border-radius: 3px;
  background: #26233a;
  color: var(--muted);
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
}

.country-panel {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  max-height: 330px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  box-shadow: 0 24px 50px rgba(0, 0, 0, 0.55);
  overflow: hidden;
}

.country-search {
  display: block;
  width: 100%;
  height: 46px;
  margin: 0;
  padding: 0 16px;
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  outline: none;
  box-shadow: none;
}

.form-group .country-search,
.form-group .country-search:focus {
  height: 46px;
  padding: 0 16px;
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  font-size: 0.95rem;
}

.country-search::placeholder {
  color: #77738f;
}

.country-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.country-list li {
  list-style: none;
  margin: 0;
  padding: 0;
}

.country-option {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  margin: 0;
  padding: 11px 16px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 0.93rem;
  text-align: left;
  cursor: pointer;
}

.country-option:hover,
.country-option.is-active {
  background: rgba(255, 255, 255, 0.08);
  outline: none;
}

.country-option[aria-selected="true"] {
  background: var(--primary-soft);
}

.country-option .name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.country-option .dial {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.country-empty {
  padding: 18px 16px;
  color: var(--muted);
  font-size: 0.9rem;
}

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 50px;
  padding: 0 20px;
  border: 0;
  border-radius: var(--radius-field);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 0.2s ease, opacity 0.2s ease, transform 0.1s ease;
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

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

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 10px 24px rgba(124, 92, 255, 0.35);
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-success {
  background: var(--success);
  color: #fff;
}

.btn-success:hover:not(:disabled) {
  background: #15803d;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.13);
}

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

.btn-danger:hover:not(:disabled) {
  background: #b91c1c;
}

.btn-sm {
  width: auto;
  height: auto;
  padding: 8px 14px;
  font-size: 0.84rem;
  box-shadow: none;
}

.btn-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ---------- Page admin ---------- */
.admin-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

.admin-toolbar h2 {
  margin-bottom: 0;
}

.toolbar-actions {
  display: flex;
  gap: 8px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.stat {
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.stat-value {
  display: block;
  font-size: 1.6rem;
  font-weight: 800;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}

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

.table-responsive {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th,
td {
  padding: 14px 12px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.82rem;
}

tbody tr:hover td {
  background: rgba(255, 255, 255, 0.025);
}

code {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 8px;
  background: var(--field);
  border: 1px solid var(--border);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9rem;
  letter-spacing: 0.12em;
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
}

.badge-success {
  background: rgba(22, 163, 74, 0.2);
  color: #86efac;
}

.badge-pending {
  background: rgba(234, 179, 8, 0.2);
  color: #fde047;
}

.actions-cell .btn + .btn {
  margin-left: 6px;
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 28px;
}

.hidden {
  display: none !important;
}

/* ---------- Écrans plus larges ---------- */
@media (min-width: 640px) {
  body {
    padding: 56px 20px 72px;
  }

  .card {
    padding: 40px 36px;
  }

  .btn-group {
    flex-direction: row;
  }

  .btn-group .btn {
    width: auto;
    flex: 1;
  }
}

/* ---------- Tableau admin → cartes sur téléphone ---------- */
@media (max-width: 720px) {
  .stats {
    gap: 8px;
  }

  .stat {
    padding: 12px;
  }

  .table-responsive {
    overflow-x: visible;
  }

  table,
  tbody,
  tr,
  td {
    display: block;
    width: 100%;
  }

  thead {
    display: none;
  }

  tbody tr {
    margin-bottom: 12px;
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface-2);
  }

  tbody tr:hover td {
    background: transparent;
  }

  td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    white-space: normal;
    overflow-wrap: anywhere;
    text-align: right;
  }

  td::before {
    content: attr(data-label);
    flex: none;
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 600;
    text-align: left;
  }

  td:last-child {
    border-bottom: 0;
  }

  td.actions-cell {
    padding-top: 14px;
    gap: 8px;
  }

  td.actions-cell::before {
    content: none;
  }

  td.actions-cell .btn {
    flex: 1;
    margin: 0;
  }

  td.empty {
    display: block;
    text-align: center;
  }

  td.empty::before {
    content: none;
  }
}

/* ---------- Très petits écrans ---------- */
@media (max-width: 380px) {
  .card {
    padding: 26px 18px;
  }

  .phone-field {
    gap: 8px;
  }

  .country-btn {
    padding: 0 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
