/* =====================================================================
   base.css – shared by every page.
   1. Design tokens (colors, fonts, sizes) – change the look here
   2. Reset & base elements
   3. Layout helpers
   4. Buttons
   5. Forms
   6. Cards, badges, chips
   7. Shared app header (store + admin)
   8. Tables
   9. Dialogs (pop-up windows)
   10. Toasts (notifications) & page loader
   ===================================================================== */

/* ---------- 1. Design tokens ---------- */
:root {
  /* Colors taken from the SCT badge: black, silver and the blue ring */
  --color-bg: #05080d;
  --color-bg-raised: #0a111b;
  --color-surface: rgba(14, 22, 34, 0.72);
  --color-surface-solid: #0d1520;
  --color-surface-hover: rgba(255, 255, 255, 0.05);
  --color-border: rgba(255, 255, 255, 0.09);
  --color-border-strong: rgba(255, 255, 255, 0.16);

  --color-text: #e7edf3;
  --color-text-muted: #8f9cab;
  --color-silver: #a7a9ac;

  --color-primary: #1e9be0;
  --color-primary-strong: #47b4f1;
  --color-primary-soft: rgba(30, 155, 224, 0.14);
  --color-on-primary: #ffffff;

  --color-danger: #ff6b78;
  --color-danger-soft: rgba(255, 107, 120, 0.13);
  --color-success: #3ddc97;
  --color-success-soft: rgba(61, 220, 151, 0.13);
  --color-warning: #f5b544;
  --color-warning-soft: rgba(245, 181, 68, 0.14);

  /* Fonts */
  --font-heading: 'Montserrat', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;

  /* Sizes */
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --radius-pill: 999px;
  --container: 1160px;
  --gutter: 16px;

  /* Effects */
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  --glow: 0 0 0 1px rgba(30, 155, 224, 0.4), 0 10px 30px rgba(30, 155, 224, 0.2);
  --blur: blur(14px);
  --transition: 160ms ease;
}

@media (min-width: 640px) {
  :root { --gutter: 24px; }
}

/* ---------- 2. Reset & base elements ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  margin: 0 0 0.5em;
  font-family: var(--font-heading);
  line-height: 1.15;
  letter-spacing: 0.01em;
}

p { margin: 0 0 1em; }

a {
  color: var(--color-primary-strong);
  text-decoration: none;
}
a:hover { text-decoration: underline; }

img { max-width: 100%; display: block; }

button, input, select, textarea { font: inherit; color: inherit; }

:focus-visible {
  outline: 2px solid var(--color-primary-strong);
  outline-offset: 2px;
}

[hidden] { display: none !important; }

/* Hidden visually but still read by screen readers */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 100;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  background: var(--color-primary);
  color: var(--color-on-primary);
}
.skip-link:focus { top: 12px; }

/* ---------- 3. Layout helpers ---------- */
.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.eyebrow {
  margin: 0 0 12px;
  font-family: var(--font-heading);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--color-primary-strong);
}

.section-title {
  font-size: clamp(1.35rem, 2.6vw, 1.75rem);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.muted { color: var(--color-text-muted); }

.text-gradient {
  background: linear-gradient(90deg, #ffffff 0%, var(--color-primary-strong) 60%, var(--color-primary) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* Faint SCT badge behind private pages.
   "screen" blending makes the black around the badge invisible. */
.watermark {
  background:
    radial-gradient(ellipse 90% 50% at 50% 0%, rgba(30, 155, 224, 0.12), transparent 70%) fixed,
    var(--color-bg);
}
.watermark::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background: url('../img/bg-watermark-ij.webp') center 55% / min(1000px, 130vw) no-repeat;
  opacity: 0.07;
  mix-blend-mode: screen;
  pointer-events: none;
}

/* ---------- 4. Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 20px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--color-surface-hover);
  color: var(--color-text);
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.2;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--transition), border-color var(--transition), box-shadow var(--transition), transform var(--transition);
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn--primary {
  background: linear-gradient(180deg, var(--color-primary-strong), var(--color-primary));
  color: var(--color-on-primary);
  box-shadow: 0 6px 20px rgba(30, 155, 224, 0.3);
}
.btn--primary:hover:not(:disabled) { box-shadow: 0 8px 26px rgba(30, 155, 224, 0.45); }

.btn--ghost {
  background: transparent;
  border-color: var(--color-border-strong);
}
.btn--ghost:hover:not(:disabled) {
  background: var(--color-surface-hover);
  border-color: var(--color-primary);
}

.btn--danger {
  background: var(--color-danger-soft);
  border-color: rgba(255, 107, 120, 0.35);
  color: var(--color-danger);
}
.btn--danger:hover:not(:disabled) { background: rgba(255, 107, 120, 0.22); }

.btn--success {
  background: var(--color-success-soft);
  border-color: rgba(61, 220, 151, 0.35);
  color: var(--color-success);
}
.btn--success:hover:not(:disabled) { background: rgba(61, 220, 151, 0.22); }

.btn--sm { min-height: 36px; padding: 6px 14px; font-size: 0.85rem; border-radius: var(--radius-sm); }
.btn--block { width: 100%; }

.btn--link {
  min-height: auto;
  padding: 0;
  background: none;
  border: 0;
  color: var(--color-primary-strong);
  font-weight: 500;
}
.btn--link:hover { text-decoration: underline; }

/* Spinner shown while a button is working */
.btn.is-busy { position: relative; color: transparent !important; }
.btn.is-busy::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 5. Forms ---------- */
.field {
  display: grid;
  gap: 6px;
  margin-bottom: 16px;
}

.field__label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-silver);
}

.input,
.select,
.textarea {
  width: 100%;
  min-height: 46px;
  padding: 10px 14px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.35);
  color: var(--color-text);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.input::placeholder { color: #5f6b78; }
.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-soft);
}
.select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--color-silver) 50%), linear-gradient(135deg, var(--color-silver) 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 36px; }
.select option { background: var(--color-surface-solid); }
.textarea { min-height: 80px; resize: vertical; }

/* Input with a button inside (e.g. show password) */
.input-group { position: relative; }
.input-group .input { padding-right: 52px; }
.input-group__btn {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
}
.input-group__btn:hover { color: var(--color-text); background: var(--color-surface-hover); }

/* Custom checkbox */
.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
  font-size: 0.92rem;
}
.checkbox input {
  appearance: none;
  flex: none;
  width: 20px;
  height: 20px;
  margin: 0;
  border: 1.5px solid var(--color-border-strong);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.35);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
}
.checkbox input::after {
  content: '';
  width: 10px;
  height: 6px;
  border-left: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: rotate(-45deg) translate(1px, -1px) scale(0);
  transition: transform var(--transition);
}
.checkbox input:checked { background: var(--color-primary); border-color: var(--color-primary); }
.checkbox input:checked::after { transform: rotate(-45deg) translate(1px, -1px) scale(1); }

.form-message {
  margin: 0 0 16px;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 0.9rem;
}
.form-message--error { background: var(--color-danger-soft); color: var(--color-danger); }
.form-message--success { background: var(--color-success-soft); color: var(--color-success); }

/* ---------- 6. Cards, badges, chips ---------- */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  background: var(--color-surface-hover);
  color: var(--color-silver);
}
.badge--success { background: var(--color-success-soft); color: var(--color-success); }
.badge--danger { background: var(--color-danger-soft); color: var(--color-danger); }
.badge--warning { background: var(--color-warning-soft); color: var(--color-warning); }
.badge--primary { background: var(--color-primary-soft); color: var(--color-primary-strong); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 6px 16px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--color-silver);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition);
}
.chip:hover { color: var(--color-text); border-color: var(--color-primary); }
.chip.is-active {
  background: var(--color-primary-soft);
  border-color: var(--color-primary);
  color: var(--color-text);
}

/* Interac address box: label + "Copier" on the first line, the address below.
   The address is plain text (no link); one click selects all of it. */
.interac {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 6px 10px;
  padding: 10px 12px;
  border: 1px solid rgba(71, 180, 241, 0.35);
  border-radius: var(--radius);
  background: rgba(30, 155, 224, 0.08);
  text-align: left;
}
.interac__label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-primary-strong);
}
.interac__email {
  grid-column: 1 / -1;
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--color-text);
  overflow-wrap: anywhere;
  user-select: all;
}
.interac__copy {
  min-height: 34px;
  padding: 4px 14px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-pill);
  background: transparent;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}
.interac__copy:hover { border-color: var(--color-primary); background: var(--color-primary-soft); }
.interac__copy.is-done { border-color: var(--color-success); color: var(--color-success); }
.interac--large { padding: 14px 16px; }
.interac--large .interac__email { font-size: 1.08rem; }

.empty-state {
  padding: 40px 20px;
  text-align: center;
  color: var(--color-text-muted);
}
.empty-state__icon { font-size: 2rem; margin-bottom: 8px; }

/* Money colors */
.amount--owe { color: var(--color-danger); }
.amount--credit { color: var(--color-success); }
.amount--even { color: var(--color-text); }
.amount--pending { color: var(--color-warning); }

/* ---------- 7. Shared app header (store + admin) ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid var(--color-border);
  background: rgba(5, 8, 13, 0.78);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
}
.app-header__inner {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 64px;
}
/* Computers: links, name and "Déconnexion" on the right, on one line */
.app-header__menu {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-left: auto;
}
.app-header__nav {
  display: flex;
  gap: 4px;
}
.app-header__link {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--color-silver);
  font-weight: 500;
  font-size: 0.92rem;
}
.app-header__link:hover { color: var(--color-text); background: var(--color-surface-hover); text-decoration: none; }
.app-header__link.is-current { color: var(--color-text); }

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-chip__avatar {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-primary), #0b4f78);
  font-family: var(--font-heading);
  font-size: 0.8rem;
  font-weight: 700;
}
.user-chip__name { font-weight: 600; font-size: 0.92rem; }

/* Brand (logo + name), used in every header */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--color-text);
}
.brand:hover { text-decoration: none; }
.brand__logo {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12), 0 0 18px rgba(30, 155, 224, 0.35);
}
.brand__text { display: grid; line-height: 1.1; }
.brand__text strong {
  white-space: nowrap;
  font-family: var(--font-heading);
  font-size: 1rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.brand__text small { color: var(--color-text-muted); font-size: 0.75rem; letter-spacing: 0.04em; }

/* ☰ button: only on phones and small tablets */
.app-header__toggle {
  display: none;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-left: auto;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text);
  cursor: pointer;
}
.app-header__toggle:hover { background: var(--color-surface-hover); }
.app-header__toggle-close,
.app-header__toggle[aria-expanded="true"] .app-header__toggle-open { display: none; }
.app-header__toggle[aria-expanded="true"] .app-header__toggle-close { display: block; }

/* Phones and small tablets: the menu folds into the ☰ button and opens
   as a panel under the header (one item per line, nothing goes off-screen) */
@media (max-width: 959px) {
  .app-header__toggle { display: grid; }
  .app-header__menu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    padding: 12px var(--gutter) 16px;
    border-bottom: 1px solid var(--color-border-strong);
    background: var(--color-surface-solid);
    box-shadow: 0 18px 30px rgba(0, 0, 0, 0.45);
  }
  .app-header.is-open .app-header__menu { display: flex; }
  .app-header__nav { flex-direction: column; gap: 2px; }
  .app-header__link { padding: 12px; font-size: 1rem; }
  .user-chip {
    order: -1; /* who is logged in, at the top of the menu */
    padding: 4px 12px 10px;
    border-bottom: 1px solid var(--color-border);
  }
  .app-header__menu #logout-btn { width: 100%; margin-top: 6px; }
}
@media (max-width: 400px) {
  .brand__text small { display: none; }
}

/* ---------- 8. Tables ---------- */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
}
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
.table th,
.table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}
.table th {
  position: sticky;
  top: 0;
  background: var(--color-surface-solid);
  color: var(--color-text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--color-surface-hover); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .wrap { white-space: normal; min-width: 180px; }
.table tr.is-clickable { cursor: pointer; }

/* ---------- 9. Dialogs ---------- */
.dialog {
  width: min(520px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  padding: 0;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-lg);
  background: var(--color-surface-solid);
  color: var(--color-text);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
}
.dialog--small { width: min(420px, calc(100vw - 32px)); }
.dialog--wide { width: min(760px, calc(100vw - 32px)); }
.dialog::backdrop {
  background: rgba(2, 4, 8, 0.7);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}
.dialog[open] { animation: dialog-in 180ms ease-out; }
.dialog__body { padding: 24px; }
.dialog__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}
.dialog__title { margin: 0 0 8px; font-size: 1.15rem; }
.dialog__text { color: var(--color-text-muted); }
.dialog__close {
  flex: none;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--color-surface-hover);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
}
.dialog__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

@keyframes dialog-in {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

/* ---------- 10. Toasts & page loader ---------- */
.toast-region {
  position: fixed;
  left: 50%;
  bottom: 20px;
  z-index: 1000;
  display: grid;
  gap: 10px;
  width: min(440px, calc(100vw - 32px));
  transform: translateX(-50%);
  pointer-events: none; /* clicks pass through the empty area around toasts */
}
.toast-region > .is-visible { pointer-events: auto; } /* a toast fading out doesn't catch clicks */
.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 12px 12px 16px;
  border: 1px solid var(--color-border-strong);
  border-left: 4px solid var(--color-primary);
  border-radius: var(--radius);
  background: var(--color-surface-solid);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 220ms ease, transform 220ms ease;
}
.toast.is-visible { opacity: 1; transform: none; }
.toast--success { border-left-color: var(--color-success); }
.toast--error { border-left-color: var(--color-danger); }
.toast--warning { border-left-color: var(--color-warning); }
.toast__msg { flex: 1; font-size: 0.92rem; }
.toast__action {
  border: 0;
  background: none;
  color: var(--color-primary-strong);
  font-weight: 700;
  cursor: pointer;
  padding: 6px 8px;
}
.toast__close {
  border: 0;
  background: none;
  color: var(--color-text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px 8px;
}

/* Full-screen loader while we check who is logged in */
.page-loader {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: none;
  place-items: center;
  background: var(--color-bg);
}
.page-loader img {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  animation: pulse 1.6s ease-in-out infinite;
}
body.is-loading .page-loader { display: grid; }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(30, 155, 224, 0.5); }
  50% { box-shadow: 0 0 0 18px rgba(30, 155, 224, 0); }
}

/* Respect people who turned off animations in their system settings */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
