/* Dédale — layout Iris + bleu acier (pas électrique) */
:root {
  --sidebar-width: 230px;
  --sidebar-collapsed-width: 60px;
  --topbar-height: 52px;
  --sidebar-bg: #1e3a5f;
  --sidebar-text: #a8c0d8;
  --sidebar-active: #ffffff;
  --sidebar-active-bg: rgba(91, 143, 185, 0.22);
  --sidebar-hover-bg: rgba(91, 143, 185, 0.1);
  --brand-color: #5b8fb9;
  --brand-strong: #3d6a8f;
  --page-bg: #f0f4f8;
  --surface: #ffffff;
  --border: #d9e2ec;
  --text: #1a2332;
  --muted: #627d98;
}

body {
  font-family: "Plus Jakarta Sans", system-ui, sans-serif;
  background: var(--page-bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
  margin: 0;
}

/* ── Sidebar (Iris) ───────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 100;
  transition: width 0.2s ease;
  overflow: hidden;
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed-width);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  min-height: var(--topbar-height);
}

.sidebar-collapse-btn {
  color: var(--sidebar-text) !important;
  padding: 2px 6px;
  line-height: 1;
  text-decoration: none;
}
.sidebar-collapse-btn:hover { color: #fff !important; }
.sidebar.collapsed .sidebar-collapse-btn { display: none; }

.brand-icon {
  font-size: 1.4rem;
  color: var(--brand-color);
  flex-shrink: 0;
}

.brand-name {
  font-weight: 700;
  font-size: 1.05rem;
  color: #fff;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.sidebar.collapsed .brand-name,
.sidebar.collapsed .nav-item span,
.sidebar.collapsed .nav-section-label,
.sidebar.collapsed .sidebar-footer span {
  display: none;
}

.nav-group { margin-bottom: 4px; }
.nav-group-items {
  list-style: none;
  padding: 0;
  margin: 0;
}
.sidebar.collapsed .nav-group-items { display: block !important; }
.sidebar.collapsed .nav-group details:not([open]) .nav-group-items { display: block !important; }

.nav-section-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  list-style: none;
}
.nav-section-toggle::-webkit-details-marker { display: none; }
.nav-section-toggle::marker { content: ""; }
.nav-section-toggle::after {
  content: "▾";
  font-size: 0.7rem;
  opacity: 0.5;
  transition: transform 0.15s;
}
details[open] > .nav-section-toggle::after { transform: rotate(180deg); }
.sidebar.collapsed .nav-section-toggle::after { display: none; }

.sidebar-nav {
  list-style: none;
  padding: 12px 8px;
  margin: 0;
  flex: 1;
  overflow-y: auto;
}

.nav-section-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.3);
  padding: 10px 10px 4px;
  white-space: nowrap;
}

.sidebar-nav .nav-item {
  border-radius: 6px;
  margin-bottom: 2px;
}

.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 0.875rem;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.sidebar-nav .nav-link i {
  font-size: 1rem;
  flex-shrink: 0;
  width: 20px;
  text-align: center;
}

.sidebar-nav .nav-item:hover .nav-link {
  background: var(--sidebar-hover-bg);
  color: #fff;
}

.sidebar-nav .nav-item.active .nav-link {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active);
  font-weight: 600;
  box-shadow: inset 2px 0 0 var(--brand-color);
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  font-size: 0.8rem;
  color: var(--sidebar-text);
}

.sidebar-footer .btn-outline-light {
  border-color: rgba(255, 255, 255, 0.25);
  color: var(--sidebar-text);
}

.sidebar-footer .btn-outline-light:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.4);
}

.sidebar.collapsed .sidebar-nav .nav-link {
  justify-content: center;
  padding: 10px;
}

.sidebar.collapsed .sidebar-footer {
  justify-content: center;
  padding: 12px;
}

/* ── Main + topbar ────────────────────────────────── */
.main-wrapper {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left 0.2s ease;
}

.main-wrapper.sidebar-collapsed {
  margin-left: var(--sidebar-collapsed-width);
}

body.view-only-mode .main-wrapper {
  margin-left: 0;
}

.topbar {
  height: var(--topbar-height);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar .breadcrumb {
  font-size: 0.82rem;
}

.topbar .breadcrumb-item.active {
  color: var(--muted);
}

.sidebar-toggle {
  color: var(--muted);
  padding: 4px 8px;
  margin-right: 4px;
  text-decoration: none;
}

.content {
  padding: 24px;
  flex: 1;
  max-width: 1200px;
  width: 100%;
}

body.content-fullwidth .content {
  max-width: none;
  padding-left: 16px;
  padding-right: 16px;
}

/* ── Bootstrap brand overrides ────────────────────── */
.btn-primary {
  --bs-btn-bg: var(--brand-strong);
  --bs-btn-border-color: var(--brand-strong);
  --bs-btn-hover-bg: #345a7a;
  --bs-btn-hover-border-color: #345a7a;
  --bs-btn-active-bg: #2f516e;
  --bs-btn-active-border-color: #2f516e;
  --bs-btn-disabled-bg: var(--brand-strong);
  --bs-btn-disabled-border-color: var(--brand-strong);
}

.table-brand {
  --bs-table-color: #fff;
  --bs-table-bg: var(--brand-strong);
  --bs-table-border-color: #345a7a;
}

.btn-outline-primary {
  --bs-btn-color: var(--brand-strong);
  --bs-btn-border-color: var(--brand-strong);
  --bs-btn-hover-bg: var(--brand-strong);
  --bs-btn-hover-border-color: var(--brand-strong);
  --bs-btn-active-bg: var(--brand-strong);
  --bs-btn-active-border-color: var(--brand-strong);
}

.text-primary {
  color: var(--brand-strong) !important;
}

a:not(.nav-link):not(.btn):not(.navbar-brand) {
  color: var(--brand-strong);
}

code {
  font-size: 0.875em;
  color: var(--brand-strong);
}

/* ── Composants métier ────────────────────────────── */
.status-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
}

.status-badge--baserow {
  background: #e6eef5;
  color: var(--brand-strong);
}

.status-badge--local {
  background: #eef2f6;
  color: var(--muted);
}

.status-badge--error {
  background: #fef2f2;
  color: #b91c1c;
}

.profile-hero {
  background: linear-gradient(135deg, var(--sidebar-bg) 0%, var(--brand-strong) 100%);
  border-radius: 1.25rem;
  color: #fff;
  padding: 2rem;
  margin-bottom: 1.5rem;
}

.profile-hero__avatar {
  width: 4rem;
  height: 4rem;
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  font-weight: 700;
}

.rule-card,
.page-card,
.onboarding-card,
.client-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 1.25rem;
  box-shadow: 0 4px 12px rgba(30, 58, 95, 0.04);
}

.rule-card {
  margin-bottom: 1.25rem;
  overflow: hidden;
}

.rule-card__header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid #eef2f6;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.rule-card__body {
  padding: 0.5rem 1.25rem 1rem;
}

.rule-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid #f5f7fa;
}

.rule-row:last-child {
  border-bottom: none;
}

.rule-row__label {
  flex: 1;
  min-width: 0;
}

.rule-row__label strong {
  font-weight: 600;
  color: var(--text);
}

.rule-row__value {
  width: 11rem;
  flex-shrink: 0;
}

.rule-row__value.is-disabled {
  opacity: 0.45;
  pointer-events: none;
}

.form-switch-lg .form-check-input {
  width: 2.5rem;
  height: 1.35rem;
  cursor: pointer;
}

.form-check-input:checked {
  background-color: var(--brand-strong);
  border-color: var(--brand-strong);
}

.client-card {
  padding: 1.25rem;
  transition: box-shadow 0.15s, border-color 0.15s;
  height: 100%;
}

.client-card:hover {
  border-color: #b8cce0;
  box-shadow: 0 8px 24px rgba(30, 58, 95, 0.08);
}

.client-card__avatar {
  width: 3rem;
  height: 3rem;
  border-radius: 0.875rem;
  background: #e6eef5;
  color: var(--brand-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
}

.onboarding-card {
  box-shadow: 0 8px 32px rgba(30, 58, 95, 0.06);
}

.maj-banner {
  background: #eef2f6;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  color: var(--muted);
}

.result-hero {
  background: linear-gradient(135deg, #eef4fa 0%, var(--surface) 100%);
  border: 1px solid var(--border);
  border-radius: 1.25rem;
  color: inherit;
  padding: 1.75rem;
}

.result-hero__eyebrow {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--brand-strong);
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.result-hero__meta {
  font-size: 0.9rem;
  color: var(--muted);
}

.result-hero__meta code {
  color: var(--brand-strong);
  background: rgba(91, 143, 185, 0.12);
  padding: 0.1rem 0.4rem;
  border-radius: 0.35rem;
}

.result-kpis {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.result-kpi {
  background: rgba(91, 143, 185, 0.08);
  border: 1px solid var(--border);
  border-radius: 0.875rem;
  padding: 0.5rem 0.875rem;
  min-width: 6rem;
}

.result-kpi__label {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.result-kpi__value {
  font-weight: 700;
  font-size: 1rem;
}

.result-kpi .form-control,
.result-kpi .input-group-text {
  background: var(--surface);
  border-color: var(--border);
}

.result-kpi .btn-outline-secondary {
  white-space: nowrap;
}

.op-badge {
  display: inline-block;
  background: #e6eef5;
  color: var(--brand-strong);
  font-weight: 700;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  font-size: 0.875rem;
}

/* En-têtes sections résultat (collapse wraps) */
.page-card > .border-bottom h2.h6 {
  letter-spacing: 0.04em;
  font-weight: 600;
}

.alertes-reliquat {
  background: linear-gradient(180deg, #fde8e8 0%, #fff5f5 100%);
  border-left: 4px solid #b42318;
}

/* ── Login ────────────────────────────────────────── */
body.login-page {
  align-items: center;
  justify-content: flex-start;
  background:
    radial-gradient(ellipse at 15% 0%, #d6e4f0 0%, transparent 50%),
    radial-gradient(ellipse at 85% 100%, #e8eef4 0%, transparent 45%),
    var(--page-bg);
  position: relative;
  padding-left: clamp(24px, 8vw, 120px);
}

@media (max-width: 768px) {
  body.login-page {
    justify-content: center;
    padding-left: 0;
  }
}

.login-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-size: cover;
  background-position: center;
}

.login-wrapper {
  width: 100%;
  max-width: 380px;
  padding: 16px;
}

.login-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
}

.btn-dedale-login {
  background: var(--brand-strong);
  border-color: var(--brand-strong);
  color: #fff;
  font-weight: 600;
}

.btn-dedale-login:hover {
  background: #345a7a;
  border-color: #345a7a;
  color: #fff;
}
