/* ==========================================================================
   Emploi du Temps — design tokens
   Palette "tableau noir / craie" : chrome sobre en teinte pin/chalk pour
   laisser les couleurs des cours (personnalisables) porter l'information.
   ========================================================================== */

:root {
  --bg: #F4F5F1;
  --surface: #FFFFFF;
  --surface-alt: #E9ECE6;
  --ink: #1C2321;
  --ink-soft: #5B655F;
  --border: #DCE0D8;
  --accent: #2C6E63;
  --accent-strong: #1F544C;
  --accent-ink: #FFFFFF;
  --accent-soft: #DCEAE6;
  --danger: #B3261E;
  --danger-soft: #F8DEDC;
  --success: #2E7D32;
  --success-soft: #DDEEDC;
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;
  --shadow: 0 1px 2px rgba(28, 35, 33, .08), 0 8px 24px rgba(28, 35, 33, .08);
  --font-display: "Space Grotesk", "Inter", sans-serif;
  --font-body: "Inter", "Space Grotesk", sans-serif;
  color-scheme: light;
}

html[data-theme="dark"] {
  --bg: #131F1A;
  --surface: #1B2924;
  --surface-alt: #223229;
  --ink: #ECEEE8;
  --ink-soft: #A6B2A9;
  --border: #2C3D34;
  --accent: #E8B65A;
  --accent-strong: #F2C878;
  --accent-ink: #1C2321;
  --accent-soft: #3A2E19;
  --danger: #FF7A6E;
  --danger-soft: #3A2321;
  --success: #7BC67E;
  --success-soft: #1F3123;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 12px 28px rgba(0, 0, 0, .35);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

/* Garantit que l'attribut HTML "hidden" masque toujours l'élément, même si
   une classe définit par ailleurs sa propriété "display" (ex: .banner). */
[hidden] { display: none !important; }

html, body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background-color .2s ease, color .2s ease;
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 .4em;
  color: var(--ink);
}

a { color: var(--accent-strong); }
html[data-theme="dark"] a { color: var(--accent); }

p { color: var(--ink-soft); }

button { font-family: inherit; }

/* -------------------------------------------------------------------- */
/* Top bar                                                               */
/* -------------------------------------------------------------------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar__brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--ink);
  text-decoration: none;
}

.topbar__logo {
  width: 48px !important;
  height: 48px !important;
  max-width: 48px !important;
  max-height: 48px !important;
  border-radius: 8px;
  object-fit: contain;
  vertical-align: middle;
  flex-shrink: 0;
}

.topbar__grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 2px;
  width: 26px;
  height: 20px;
}
.topbar__grid span {
  background: var(--border);
  border-radius: 2px;
}
.topbar__grid span:nth-child(3) { background: var(--accent); }

.topbar__actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-soft);
  cursor: pointer;
  text-decoration: none;
  transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}
.icon-btn:hover {
  background: var(--surface-alt);
  color: var(--ink);
}
.icon-btn--active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
}

.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 18px 60px;
}

/* -------------------------------------------------------------------- */
/* Boutons & alertes                                                     */
/* -------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  padding: 10px 16px;
  font-weight: 600;
  font-size: .95rem;
  cursor: pointer;
  transition: background-color .15s ease, color .15s ease, border-color .15s ease, transform .1s ease;
}
.btn:active { transform: translateY(1px); }

.btn--primary {
  background: var(--accent);
  color: var(--accent-ink);
}
.btn--primary:hover { background: var(--accent-strong); }

.btn--secondary {
  background: var(--surface-alt);
  color: var(--ink);
  border: 1px solid var(--border);
}
.btn--secondary:hover {
  background: var(--border);
}

.btn--danger {
  background: var(--danger);
  color: #FFFFFF;
}
.btn--danger:hover {
  background: #961D17;
}

.btn--ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--ink);
}
.btn--ghost:hover { background: var(--surface-alt); }

.btn--icon {
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 999px;
  border-color: var(--border);
  background: var(--surface);
  color: var(--ink);
}
.btn--icon:hover { background: var(--surface-alt); }

.alert {
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 16px;
  font-size: .92rem;
}
.alert--error { background: var(--danger-soft); color: var(--danger); }
.alert--success { background: var(--success-soft); color: var(--success); }

.banner {
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin: 14px 0;
  font-size: .88rem;
  text-align: center;
}
.banner--offline { background: var(--accent-soft); color: var(--accent-strong); }
.banner--error { background: var(--danger-soft); color: var(--danger); }

/* -------------------------------------------------------------------- */
/* Page d'accueil / configuration du lien                                */
/* -------------------------------------------------------------------- */

.setup {
  min-height: calc(100vh - 64px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 0;
}

.setup__card {
  width: 100%;
  max-width: 460px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 36px 32px;
}

.setup__grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  width: 72px;
  height: 56px;
  margin-bottom: 22px;
}
.setup__grid span { background: var(--surface-alt); border-radius: 4px; }
.setup__grid span:nth-child(2) { background: var(--accent); }
.setup__grid span:nth-child(4) { background: var(--accent); opacity: .55; }

.setup__card h1 {
  font-size: 1.5rem;
  max-width: 22ch;
}

.setup__lead {
  font-size: .95rem;
  max-width: 42ch;
}

.setup__form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 22px;
}
.setup__form label {
  font-size: .82rem;
  font-weight: 600;
  color: var(--ink-soft);
}
.setup__form input[type="url"] {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: .95rem;
  background: var(--bg);
  color: var(--ink);
}
.setup__form input[type="url"]:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.setup__form .btn { margin-top: 6px; }

.setup__hint {
  margin-top: 18px;
  font-size: .8rem;
  color: var(--ink-soft);
}

/* -------------------------------------------------------------------- */
/* Réglages                                                              */
/* -------------------------------------------------------------------- */

.settings { padding-top: 26px; max-width: 640px; }
.settings h1 { font-size: 1.6rem; }

.settings__section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 18px;
}
.settings__section h2 { font-size: 1.05rem; }
.settings__desc { font-size: .88rem; margin-bottom: 14px; }

.settings__form { display: flex; gap: 10px; margin-top: 6px; flex-wrap: wrap; }
.settings__form input[type="url"] {
  flex: 1 1 220px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: var(--bg);
  color: var(--ink);
  font-size: .92rem;
}
.settings__form--danger { margin-top: 14px; }

.theme-choice { display: flex; gap: 10px; }
.theme-choice__btn {
  flex: 1;
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--ink);
  font-weight: 600;
  cursor: pointer;
}
.theme-choice__btn.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.color-grid {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 14px;
}
.color-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 4px;
  border-bottom: 1px solid var(--border);
}
.color-row:last-child { border-bottom: none; }
.color-row__swatch {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  flex-shrink: 0;
  border: 1px solid rgba(0,0,0,.1);
}
.color-row__label { flex: 1; font-size: .92rem; }
.color-row input[type="color"] {
  width: 40px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px;
  background: var(--surface);
  cursor: pointer;
}

.back-link {
  display: inline-block;
  margin-top: 8px;
  font-size: .9rem;
  text-decoration: none;
}

@media (max-width: 560px) {
  .setup__card { padding: 28px 22px; }
  .page { padding: 0 12px 40px; }
}
