/* ============================================================
   Data DestockCBD — Styles
   Esprit Limbus : sobre, fonctionnel, cards relevées,
   bons contrastes, ne se prend pas pour Apple.
   ============================================================ */

/* -- Reset léger -- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: #1f2933;
  background: #f5f7fa;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* -- Variables couleurs --
   Palette inspirée du contexte DestockCBD (vert nature) tout en gardant
   les codes Limbus pour la cohérence transverse (jaune accent, neutres). */
:root {
  --c-bg:           #f5f7fa;
  --c-card:         #ffffff;
  --c-zebra:        #f5f7fa;
  --c-hover:        #eef2f6;
  --c-border:       #d6dadd;
  --c-border-hard:  #1f2933;
  --c-text:         #1f2933;
  --c-text-soft:    #5a6473;
  --c-text-muted:   #8b95a3;

  /* Accent principal : vert nature (DestockCBD) */
  --c-accent:       #2d7a3e;
  --c-accent-hov:   #235f30;
  --c-accent-soft:  #e8f3eb;

  /* Accent secondaire : jaune Limbus pour boutons actifs / filtres */
  --c-yellow:       #fbcc05;
  --c-yellow-hov:   #e6b800;

  /* Statuts */
  --c-ok:           #10b981;
  --c-warning:      #FF8C42;
  --c-critical:     #E62A2A;
  --c-muted:        #6B7280;

  /* Indigo pour stat cards "nouveau" */
  --c-indigo:       #2C2877;
}

a { color: var(--c-accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0 0 0.6em; line-height: 1.25; color: var(--c-text); }
h1 { font-size: 1.6rem; font-weight: 700; }
h2 { font-size: 1.25rem; font-weight: 600; }
h3 { font-size: 1.05rem; font-weight: 600; }

p { margin: 0 0 1em; }

/* ============================================================
   Layout principal authentifié
   ============================================================ */
.app-layout { display: flex; flex-direction: column; min-height: 100vh; }

.topbar {
  background: var(--c-card);
  border-bottom: 1px solid var(--c-border);
  padding: 0;
  display: flex;
  align-items: center;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-inner {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}
.topbar-brand {
  font-weight: 700;
  font-size: 1rem;
  color: var(--c-text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.topbar-brand-mark {
  display: inline-block;
  width: 22px;
  height: 22px;
  background: var(--c-accent);
  border-radius: 5px;
  position: relative;
}
.topbar-brand-mark::after {
  content: "🌿";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}
.topbar-nav {
  display: flex;
  gap: 0.4rem;
  flex: 1;
}
.topbar-nav a {
  color: var(--c-text);
  padding: 0.4rem 0.7rem;
  border-radius: 6px;
  font-size: 0.92rem;
  font-weight: 500;
  text-decoration: none;
  transition: background 120ms ease;
}
.topbar-nav a:hover { background: var(--c-hover); }
.topbar-nav a.is-active {
  background: var(--c-yellow);
  color: var(--c-text);
  font-weight: 700;
}
.topbar-user {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.9rem;
}
.topbar-user a { color: var(--c-text-soft); }
.topbar-user a:hover { color: var(--c-text); text-decoration: none; }
.topbar-user .sep { color: var(--c-text-muted); }

.app-content {
  flex: 1;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
  padding: 1.5rem;
}

.app-footer {
  border-top: 1px solid var(--c-border);
  background: var(--c-card);
  text-align: center;
  font-size: 0.82rem;
  color: var(--c-text-muted);
  padding: 0.9rem 1rem;
}

/* ============================================================
   Layout AUTH (login, reset, forgot)
   Centré, sans topbar
   ============================================================ */
.auth-layout {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  background:
    radial-gradient(ellipse at top, rgba(45, 122, 62, 0.08), transparent 60%),
    var(--c-bg);
}
.auth-card {
  background: var(--c-card);
  border: 1px solid var(--c-border);
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.06);
  padding: 2rem;
  width: 100%;
  max-width: 420px;
}
.auth-brand {
  text-align: center;
  margin-bottom: 1.5rem;
}
.auth-brand-mark {
  display: inline-block;
  width: 48px;
  height: 48px;
  background: var(--c-accent);
  border-radius: 12px;
  position: relative;
  margin-bottom: 0.6rem;
}
.auth-brand-mark::after {
  content: "🌿";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}
.auth-brand h1 {
  font-size: 1.2rem;
  margin: 0;
  font-weight: 700;
}
.auth-brand .subtitle {
  color: var(--c-text-muted);
  font-size: 0.85rem;
  margin-top: 0.25rem;
}
.auth-card h2 {
  text-align: center;
  margin-bottom: 1.2rem;
  font-size: 1.1rem;
  color: var(--c-text-soft);
  font-weight: 500;
}
.auth-links {
  margin-top: 1.2rem;
  text-align: center;
  font-size: 0.88rem;
}
.auth-links a {
  color: var(--c-text-soft);
}
.auth-footer {
  text-align: center;
  margin-top: 2rem;
  font-size: 0.78rem;
  color: var(--c-text-muted);
}

/* ============================================================
   Forms
   ============================================================ */
.form-group { margin-bottom: 1rem; }
.form-group label {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--c-text);
  margin-bottom: 0.35rem;
}
.form-group label .req { color: var(--c-critical); }
.form-input,
input[type="email"],
input[type="password"],
input[type="text"],
input[type="number"],
input[type="date"],
input[type="url"],
input[type="search"],
select,
textarea {
  width: 100%;
  padding: 0.55rem 0.7rem;
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--c-text);
  background: #fff;
  border: 1px solid var(--c-border);
  border-radius: 6px;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
textarea {
  resize: vertical;
  min-height: 80px;
  line-height: 1.5;
}
.form-input:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="text"]:focus,
input[type="url"]:focus,
input[type="search"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--c-accent);
  box-shadow: 0 0 0 3px rgba(45, 122, 62, 0.15);
}
.form-help {
  font-size: 0.8rem;
  color: var(--c-text-muted);
  margin-top: 0.3rem;
}
.form-actions {
  margin-top: 1.2rem;
}

/* ============================================================
   Boutons
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.55rem 1.1rem;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--c-accent);
  color: #fff;
  border-color: var(--c-accent);
}
.btn-primary:hover:not(:disabled) {
  background: var(--c-accent-hov);
  border-color: var(--c-accent-hov);
  text-decoration: none;
}

.btn-ghost {
  background: transparent;
  color: var(--c-text);
  border-color: var(--c-border);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--c-hover);
  border-color: var(--c-border-hard);
  text-decoration: none;
}

.btn-block {
  width: 100%;
}

/* ============================================================
   Alerts / flash messages
   ============================================================ */
.alert {
  padding: 0.7rem 0.9rem;
  border-radius: 6px;
  font-size: 0.9rem;
  margin-bottom: 1rem;
  border: 1px solid transparent;
}
.alert-error {
  background: #fef2f2;
  border-color: #fecaca;
  color: #991b1b;
}
.alert-success {
  background: #f0fdf4;
  border-color: #bbf7d0;
  color: #15803d;
}
.alert-info {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1d4ed8;
}
.alert-warning {
  background: #fffbeb;
  border-color: #fde68a;
  color: #92400e;
}

/* ============================================================
   Cards
   ============================================================ */
.card {
  background: var(--c-card);
  border: 1px solid var(--c-border);
  border-radius: 8px;
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}
.card h2 {
  margin-top: 0;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--c-border);
  margin-bottom: 1rem;
}

/* ============================================================
   Tables (pour les pages futures)
   ============================================================ */
.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--c-card);
}
.table th, .table td {
  padding: 0.6rem 0.8rem;
  text-align: left;
  border-bottom: 1px solid var(--c-border);
  font-size: 0.92rem;
}
.table th {
  background: var(--c-zebra);
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--c-text-soft);
}
.table tr:nth-child(odd) td { background: #fff; }
.table tr:nth-child(even) td { background: var(--c-zebra); }
.table tr:hover td { background: var(--c-hover); }

/* Badges */
.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid transparent;
}
.badge-ok        { background: #d1fae5; color: #065f46; border-color: #6ee7b7; }
.badge-warning   { background: #fed7aa; color: #9a3412; border-color: #fdba74; }
.badge-critical  { background: #fecaca; color: #991b1b; border-color: #fca5a5; }
.badge-muted     { background: #e5e7eb; color: #374151; border-color: #d1d5db; }
.badge-indigo    { background: #ddd6fe; color: #4c1d95; border-color: #c4b5fd; }
.badge-role-super { background: #fbcc05; color: #1f2933; }
.badge-role-admin { background: #ddd6fe; color: #4c1d95; }

/* ============================================================
   Account page
   ============================================================ */
.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--c-border);
}
.info-row:last-child { border-bottom: none; }
.info-row .label {
  color: var(--c-text-muted);
  font-size: 0.88rem;
}
.info-row .value {
  font-weight: 500;
}

/* Helpers */
.text-muted  { color: var(--c-text-muted); }
.text-center { text-align: center; }
.mt-2 { margin-top: 1rem; }
.mb-2 { margin-bottom: 1rem; }

/* ============================================================
   L2 — Pages comptes : header, filtres pilules, search, pagination, grid
   ============================================================ */

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.page-header h1 {
  margin: 0;
}

/* Filtres pilules */
.filters-bar {
  margin-bottom: 1.2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--c-border);
}
.pills {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.pills-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--c-text-muted);
  margin-right: 0.4rem;
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 500;
  background: var(--c-card);
  color: var(--c-text-soft);
  border: 1px solid var(--c-border);
  text-decoration: none;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}
.pill:hover {
  background: var(--c-hover);
  color: var(--c-text);
  text-decoration: none;
}
.pill.is-active {
  background: var(--c-yellow);
  color: var(--c-text);
  border-color: var(--c-yellow);
  font-weight: 700;
}
.pill-count {
  display: inline-block;
  padding: 0.05rem 0.4rem;
  background: rgba(0, 0, 0, 0.06);
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
}
.pill.is-active .pill-count {
  background: rgba(0, 0, 0, 0.15);
}

/* Barre de recherche */
.search-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.8rem;
}
.search-bar input[type="search"] {
  flex: 1;
  max-width: 380px;
}

/* Tableau utilisateurs : colonnes adaptées */
.users-table th:first-child,
.users-table td:first-child {
  width: 30%;
}
.users-table tr:hover td {
  background: var(--c-hover);
}

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 1.2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--c-border);
}
.page-link {
  padding: 0.4rem 0.8rem;
  border: 1px solid var(--c-border);
  border-radius: 6px;
  font-size: 0.88rem;
  color: var(--c-text);
  text-decoration: none;
  background: var(--c-card);
}
.page-link:hover {
  background: var(--c-hover);
  text-decoration: none;
}
.page-info {
  font-size: 0.88rem;
  color: var(--c-text-muted);
}

/* Grille formulaire (form gauche + sidebar droite) */
.form-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.25rem;
  align-items: start;
}
.form-grid .card {
  margin-bottom: 0;
}
@media (max-width: 900px) {
  .form-grid { grid-template-columns: 1fr; }
}

/* Checkbox label horizontal */
.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.95rem;
  cursor: pointer;
  font-weight: 500 !important;
}
.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
}

/* Bouton "danger" texte (sans fond rouge agressif) */
.btn-danger-text {
  background: transparent;
  border: 1px solid #fecaca;
  color: #991b1b;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: background 120ms ease;
}
.btn-danger-text:hover {
  background: #fef2f2;
}

/* ============================================================
   L3 — Page Sites
   ============================================================ */

.sites-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 1.25rem;
}

.site-card {
  display: block;
  background: var(--c-card);
  border: 1px solid var(--c-border);
  border-radius: 8px;
  padding: 1.25rem;
  text-decoration: none;
  color: var(--c-text);
  transition: border-color 120ms ease, box-shadow 120ms ease, transform 120ms ease;
}
.site-card:hover {
  border-color: var(--c-accent);
  box-shadow: 0 4px 16px rgba(45, 122, 62, 0.10);
  text-decoration: none;
  transform: translateY(-1px);
}

.site-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.4rem;
}
.site-card-head h2 {
  font-size: 1.1rem;
  margin: 0;
  font-weight: 600;
}

.site-card-url {
  color: var(--c-text-muted);
  font-size: 0.88rem;
  margin-bottom: 0.9rem;
  word-break: break-all;
}

.site-card-meta {
  font-size: 0.85rem;
  margin-bottom: 0.8rem;
}
.meta-row {
  display: flex;
  justify-content: space-between;
  padding: 0.2rem 0;
}
.meta-label { color: var(--c-text-muted); }
.meta-value { color: var(--c-text); font-weight: 500; }

.site-counts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
  gap: 0.6rem;
  padding-top: 0.8rem;
  border-top: 1px solid var(--c-border);
}
.site-counts-large {
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  border-top: none;
  padding-top: 0;
}
.site-count {
  text-align: center;
}
.site-count-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--c-accent);
  line-height: 1.1;
}
.site-counts-large .site-count-value {
  font-size: 1.8rem;
}
.site-count-label {
  font-size: 0.72rem;
  color: var(--c-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 0.15rem;
}

/* Code inline */
code {
  background: rgba(45, 122, 62, 0.08);
  color: var(--c-accent);
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.88em;
}

/* ============================================================
   L3.3 — Branding (logo topbar/auth, footer Limbus, page settings)
   ============================================================ */

/* Logo dans la topbar : remplace le carré .topbar-brand-mark */
.topbar-brand-logo {
  height: 28px;
  width: auto;
  max-width: 160px;
  object-fit: contain;
  display: block;
}

/* Logo sur la page de connexion */
.auth-brand-logo {
  max-height: 56px;
  max-width: 220px;
  object-fit: contain;
  display: block;
  margin: 0 auto 0.5rem;
}

/* Footer multi-élément (app_name + Limbus Studio) */
.app-footer-sep {
  margin: 0 0.4rem;
  color: var(--c-text-muted);
}
.app-footer a {
  color: var(--c-text-muted);
}
.app-footer a:hover {
  color: var(--c-text);
  text-decoration: underline;
}

/* ============================================================
   Page Settings : aperçus images + grille couleurs
   ============================================================ */

.settings-form .card {
  margin-bottom: 1.25rem;
}

.branding-image-row {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
  flex-wrap: wrap;
}

.branding-image-preview {
  width: 200px;
  min-height: 80px;
  background: var(--c-zebra);
  border: 1px solid var(--c-border);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.8rem;
  flex-shrink: 0;
}

.branding-image-preview img {
  max-width: 100%;
  max-height: 80px;
  object-fit: contain;
  display: block;
}

.branding-image-preview-small {
  width: 96px;
  min-height: 96px;
  padding: 0.6rem;
}

.branding-image-preview-small img {
  max-height: 64px;
  max-width: 64px;
}

.branding-image-placeholder {
  color: var(--c-text-muted);
  font-size: 0.85rem;
  font-style: italic;
}

.branding-image-actions {
  flex: 1;
  min-width: 280px;
}

/* Grille couleurs */
.color-grid {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.color-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--c-border);
  flex-wrap: wrap;
}
.color-row:last-child { border-bottom: none; }

.color-row-label {
  flex: 1;
  min-width: 240px;
}
.color-row-desc {
  font-size: 0.82rem;
  color: var(--c-text-muted);
  margin-top: 0.15rem;
}

.color-row-input {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.color-picker {
  width: 48px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--c-border);
  border-radius: 4px;
  cursor: pointer;
  background: transparent;
}

.color-text {
  width: 100px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.88rem;
  text-transform: uppercase;
  background: var(--c-zebra);
  cursor: default;
}

.color-default-hint {
  font-size: 0.78rem;
  color: var(--c-text-muted);
}

/* Sublabel des compteurs (ventilation par statut) */
.site-count-sub {
  font-size: 0.7rem;
  color: var(--c-text-muted);
  margin-top: 0.2rem;
  font-weight: 400;
  line-height: 1.3;
}
.site-counts-large .site-count-sub {
  font-size: 0.78rem;
  margin-top: 0.3rem;
}

/* ============================================================
   L4.a — Pages catalogue stub (vides en attente de sync)
   ============================================================ */

.stub-card {
  text-align: center;
  padding: 2.5rem 1.5rem;
}

.stub-illustration {
  font-size: 3rem;
  line-height: 1;
  margin-bottom: 0.6rem;
  opacity: 0.7;
}

.stub-title {
  font-size: 1.15rem;
  margin: 0 0 0.6rem;
  border: none;
  padding: 0;
}

.stub-text {
  color: var(--c-text-soft);
  max-width: 520px;
  margin: 0 auto 1.2rem;
  line-height: 1.55;
}

.stub-next {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--c-border);
  display: inline-flex;
  gap: 0.5rem;
  align-items: center;
  font-size: 0.88rem;
}

/* ============================================================
   L4.b — Page Sync : barres de progression
   ============================================================ */

.sync-progress-block {
  margin-bottom: 1rem;
}
.sync-progress-block:last-child { margin-bottom: 0; }
.sync-progress-block.is-current .sync-progress-head strong {
  color: var(--c-accent);
}
.sync-progress-block.is-current .sync-progress-head strong::after {
  content: ' ←';
  color: var(--c-accent);
}

.sync-progress-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.4rem;
  font-size: 0.92rem;
}

.sync-progress-pct,
.sync-progress-stats {
  color: var(--c-text-muted);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

.sync-progress-bar {
  width: 100%;
  height: 10px;
  background: var(--c-zebra);
  border-radius: 5px;
  overflow: hidden;
  position: relative;
}

.sync-progress-fill {
  height: 100%;
  background: var(--c-accent);
  transition: width 0.4s ease;
  min-width: 2px;
}

/* ============================================================
   L4.c — Page Settings : grille narrow + sync hint
   ============================================================ */

.form-grid-narrow {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.form-grid-narrow .form-group {
  margin-bottom: 0;
}
