/* ===============================================================
   BASE — variables, reset, typographie, top bar
   =============================================================== */

:root {
  /* Surfaces */
  --bg: #0a0e1a;
  --bg-soft: #0f1525;
  --surface: #151c33;
  --surface-2: #1c243f;
  --surface-hover: #232b4a;
  --border: rgba(148, 163, 184, 0.16);
  --border-strong: rgba(148, 163, 184, 0.32);

  /* Accent — Ficsit Orange (Satisfactory) */
  --accent: #FA9549;
  --accent-strong: #E87A2F;
  --accent-soft: rgba(250, 149, 73, 0.14);

  /* Bleu secondaire (couleur Satisfactory complémentaire) */
  --secondary: #5B9BD5;
  --secondary-soft: rgba(91, 155, 213, 0.14);

  /* Sémantique */
  --success: #5BC246;
  --warning: #fbbf24;
  --danger: #DC3545;

  /* Texte */
  --text: #e5e7eb;
  --text-muted: #94a3b8;
  --text-faint: #64748b;

  /* Couleurs des machines (alignées sur les indicators du jeu) */
  --machine: #FA9549;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

body {
  background:
    radial-gradient(ellipse at top left, rgba(56, 189, 248, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse at top right, rgba(192, 132, 252, 0.04) 0%, transparent 50%),
    var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.tab-pane:not([hidden]) {
  flex: 1;
}

/* ===============================================================
   TOP BAR
   =============================================================== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10, 14, 26, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  height: 64px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1rem;
}

/* Brand — aligné à gauche */
.brand { justify-self: start; }

/* Tabs — centré naturellement (colonne auto) */
.tabs { justify-self: center; }

/* Contrôles — alignés à droite */
.topbar-controls {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.brand-sep {
  width: 1px;
  height: 18px;
  background: var(--border-strong);
  flex-shrink: 0;
  margin: 0 0.2rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-weight: 600;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}

.brand-logo {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #ef4444, #f97316);
  border-radius: 8px;
  color: var(--bg);
  font-weight: 800;
  font-size: 1.1rem;
  box-shadow: 0 2px 12px rgba(56, 189, 248, 0.25);
}

/* ===============================================================
   TABS
   =============================================================== */
.tabs {
  display: flex;
  gap: 0.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 0.3rem;
  border-radius: 12px;
}

.tab {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 0.6rem 2.2rem;
  border-radius: 9px;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
  text-decoration: none;
}

.tab:hover { color: var(--text); background: var(--surface-hover); }

.tab.active {
  color: var(--bg);
  background: var(--accent);
  box-shadow: 0 1px 4px rgba(56, 189, 248, 0.4);
}

/* ===============================================================
   TOPBAR — RESPONSIVE MOBILE
   =============================================================== */
@media (max-width: 700px) {
  .topbar {
    grid-template-columns: auto 1fr auto;
    padding: 0 0.75rem;
    gap: 0.5rem;
    height: 56px;
  }
  .brand-name { display: none; }
  .tab { padding: 0.45rem 0.9rem; font-size: 0.82rem; }
}

@media (max-width: 420px) {
  .tab { padding: 0.4rem 0.6rem; font-size: 0.78rem; }
}

/* ===============================================================
   PALIER SELECTOR
   =============================================================== */
.palier-selector { position: relative; }

.palier-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.45rem 0.85rem;
  border-radius: 9px;
  font-size: 0.85rem;
  font-family: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.15s ease;
}

.palier-btn:hover {
  border-color: var(--border-strong);
  background: var(--surface-hover);
}

.palier-btn .pal-label {
  color: var(--accent);
  font-weight: 600;
}

.palier-btn .pal-label.empty {
  color: var(--text-faint);
  font-weight: 400;
  font-style: italic;
}

.palier-arrow { font-size: 0.7rem; opacity: 0.6; }

.palier-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 280px;
  max-height: 70vh;
  overflow-y: auto;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  z-index: 200;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  display: none;
}

.palier-menu.open { display: block; }

.palier-item {
  padding: 0.55rem 0.85rem;
  cursor: pointer;
  font-size: 0.85rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  white-space: nowrap;
}

.palier-item:last-child { border-bottom: none; }

.palier-item:hover, .palier-item.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.palier-item.active { font-weight: 600; }

.palier-item-meta {
  font-size: 0.72rem;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

.palier-item.empty-option {
  border-bottom: 2px solid var(--border);
  font-style: italic;
  color: var(--text-muted);
}

/* ===============================================================
   CONTAINER GÉNÉRAL
   =============================================================== */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2.5rem 1.25rem 4rem;
}

/* ===============================================================
   ICÔNES — items et machines
   =============================================================== */
.item-icon {
  width: 22px;
  height: 22px;
  vertical-align: middle;
  margin-right: 6px;
  border-radius: 3px;
  object-fit: contain;
  background: rgba(255, 255, 255, 0.04);
}
.item-icon-tiny {
  width: 16px;
  height: 16px;
  vertical-align: middle;
  margin-right: 4px;
  border-radius: 2px;
  object-fit: contain;
}
.machine-icon {
  width: 28px;
  height: 28px;
  vertical-align: middle;
  margin-right: 8px;
  border-radius: 4px;
  object-fit: contain;
  background: rgba(255, 255, 255, 0.04);
}
.machine-icon-small {
  width: 22px;
  height: 22px;
  vertical-align: middle;
  margin-right: 6px;
  border-radius: 3px;
  object-fit: contain;
  background: rgba(255, 255, 255, 0.04);
}

/* ===============================================================
   MOBILE RESPONSIVE — < 900px
   =============================================================== */
@media (max-width: 900px) {
  body { padding: 0; }
  .container { padding: 0.85rem; max-width: 100%; }
}

/* Garantit que hidden n'est jamais écrasé par un display: grid/flex défini en CSS */
[hidden] { display: none !important; }

@media (max-width: 600px) {
  .topbar .brand span { display: none; }
  .topbar .tabs .tab { padding: 0.4rem 0.7rem; font-size: 0.85rem; }
}

/* ===============================================================
   MODALES CUSTOM
   =============================================================== */
.sf-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(3px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.sf-modal-overlay.sf-modal-visible { opacity: 1; }

.sf-modal {
  background: var(--bg-soft);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.7);
  padding: 1.5rem 1.75rem;
  min-width: 320px;
  max-width: 480px;
  width: 100%;
  transform: translateY(-8px);
  transition: transform 0.15s ease;
}
.sf-modal-overlay.sf-modal-visible .sf-modal { transform: translateY(0); }

.sf-modal-title {
  margin: 0 0 0.65rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}
.sf-modal-message {
  margin: 0 0 1.1rem;
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.5;
}
.sf-modal-title + .sf-modal-message { margin-top: -0.1rem; }
.sf-modal-input {
  display: block;
  width: 100%;
  box-sizing: border-box;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  padding: 0.55rem 0.8rem;
  margin-bottom: 1.1rem;
  outline: none;
  transition: border-color 0.12s ease;
}
.sf-modal-input:focus { border-color: var(--accent); }

.sf-modal-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
}
.sf-modal-btn {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--text);
  border-radius: 8px;
  padding: 0.5rem 1.1rem;
  font-family: inherit;
  font-size: 0.88rem;
  cursor: pointer;
  transition: all 0.12s ease;
}
.sf-modal-btn:hover { background: var(--surface-hover); }
.sf-modal-btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
  font-weight: 600;
}
.sf-modal-btn.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.sf-modal-btn.danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
  font-weight: 600;
}
.sf-modal-btn.danger:hover { background: #b02a37; border-color: #b02a37; }

/* ===============================================================
   TOASTS
   =============================================================== */
#sf-toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 1100;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5rem;
  pointer-events: none;
}
.sf-toast {
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  padding: 0.65rem 1rem;
  font-size: 0.85rem;
  color: var(--text);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  max-width: 320px;
  opacity: 0;
  transform: translateX(16px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.sf-toast.sf-toast-visible { opacity: 1; transform: translateX(0); }
.sf-toast.sf-toast-error  { border-left-color: var(--danger); }
.sf-toast.sf-toast-success { border-left-color: var(--success); }

/* ===============================================================
   SÉLECTEUR DE LANGUE
   =============================================================== */
.lang-switcher {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.15rem;
}
.lang-btn {
  background: transparent;
  border: none;
  color: var(--text-faint);
  font-size: 0.72rem;
  font-weight: 600;
  font-family: inherit;
  padding: 0.2rem 0.45rem;
  border-radius: 4px;
  cursor: pointer;
  letter-spacing: 0.04em;
  transition: background 0.12s, color 0.12s;
}
.lang-btn:hover { color: var(--text); }
.lang-btn.active {
  background: var(--accent);
  color: #000;
}

/* ===============================================================
   BANNIÈRE RGPD
   =============================================================== */
#sf-consent-banner {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(120%);
  z-index: 9999;
  width: min(680px, calc(100vw - 2rem));
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5), 0 0 0 1px rgba(250,149,73,0.08);
  padding: 1rem 1.25rem;
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
#sf-consent-banner.sf-consent-visible {
  transform: translateX(-50%) translateY(0);
}
.sf-consent-inner {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
}
.sf-consent-text {
  flex: 1;
  min-width: 200px;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.87rem;
  color: var(--text-muted);
  line-height: 1.5;
}
.sf-consent-icon {
  font-size: 1.4rem;
  flex-shrink: 0;
}
.sf-consent-text strong {
  color: var(--text);
}
.sf-consent-actions {
  display: flex;
  gap: 0.6rem;
  flex-shrink: 0;
}
.sf-consent-actions button {
  padding: 0.45rem 1.1rem;
  border-radius: 8px;
  font-size: 0.85rem;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
#sf-consent-decline {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
}
#sf-consent-decline:hover {
  border-color: var(--text-muted);
  color: var(--text);
}
#sf-consent-accept {
  background: var(--accent);
  border: 1px solid var(--accent);
  color: #000;
  font-weight: 600;
}
#sf-consent-accept:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

/* ---------------------------------------------------------------
   SEO footer — visible et indexable, discret visuellement
   --------------------------------------------------------------- */
html[lang="fr"] .seo-footer [lang="en"] { display: none; }
html[lang="en"] .seo-footer [lang="fr"] { display: none; }

.seo-footer {
  padding: 2rem 2rem 3rem;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.78rem;
  line-height: 1.6;
  max-width: 860px;
  margin: 0 auto;
}
.seo-footer h1 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin: 0 0 0.5rem;
  letter-spacing: 0;
}
.seo-footer p {
  margin: 0 0 0.4rem;
}
.seo-footer strong {
  color: var(--text-muted);
  font-weight: 600;
}
