/* Portail Lajus — thème sobre "outil interne d'entreprise".
   Palette : sidebar ardoise foncée, contenu gris très clair, accent bleu. */

:root {
  --sidebar-bg: #1e293b;
  --sidebar-text: #cbd5e1;
  --sidebar-active: #334155;
  --bg: #f1f5f9;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #64748b;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --danger: #b91c1c;
  --ok: #15803d;
  --radius: 8px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
}

/* ── Layout ─────────────────────────────────────────────────────────── */

.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.content {
  flex: 1;
  padding: 2rem 2.5rem;
  max-width: 1200px;
}

/* ── Sidebar ────────────────────────────────────────────────────────── */

.brand {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: 1.1rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.brand-mark {
  width: 34px; height: 34px;
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 1.05rem;
  display: flex; align-items: center; justify-content: center;
}

.brand strong { color: #fff; display: block; font-size: .95rem; line-height: 1.2; }
.brand small  { color: var(--sidebar-text); font-size: .72rem; }

.sidebar nav { flex: 1; padding: .8rem .6rem; }

.sidebar nav a {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .55rem .7rem;
  margin-bottom: 2px;
  border-radius: 6px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: .88rem;
}
.sidebar nav a:hover  { background: var(--sidebar-active); color: #fff; }
.sidebar nav a.active { background: var(--sidebar-active); color: #fff; font-weight: 600; }
.sidebar nav a svg    { flex-shrink: 0; opacity: .85; }

.nav-section {
  padding: .9rem .7rem .3rem;
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: #7c8ba1;
}

.sidebar-footer {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .9rem 1rem;
  border-top: 1px solid rgba(255, 255, 255, .08);
  font-size: .85rem;
}

.avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: #475569;
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem; font-weight: 600;
  flex-shrink: 0;
}

.sidebar-footer .user-name { flex: 1; color: #e2e8f0; overflow: hidden; text-overflow: ellipsis; }
.sidebar-footer a { color: var(--sidebar-text); display: flex; }
.sidebar-footer a:hover { color: #fff; }

/* ── Contenu ────────────────────────────────────────────────────────── */

h1 { font-size: 1.35rem; margin: 0 0 .3rem; }
h2 { font-size: 1.05rem; margin: 1.6rem 0 .6rem; }
.page-sub { color: var(--text-muted); font-size: .88rem; margin: 0 0 1.4rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem 1.3rem;
  margin-bottom: 1rem;
}

.card h3 { margin: 0 0 .35rem; font-size: .95rem; }
.card p  { margin: 0 0 .9rem; color: var(--text-muted); font-size: .86rem; line-height: 1.45; }

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

/* ── Formulaires / boutons ──────────────────────────────────────────── */

input[type="text"], input[type="password"], textarea, select {
  width: 100%;
  padding: .55rem .7rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
  background: var(--surface);
  margin-bottom: .8rem;
}
input:focus, textarea:focus { outline: 2px solid #bfdbfe; border-color: var(--accent); }

.btn {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  padding: .5rem 1rem;
  border: 1px solid transparent;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: .87rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: var(--accent-hover); }

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover { background: var(--bg); }

.exemples { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1rem; }
.exemples button {
  font: inherit;
  font-size: .78rem;
  padding: .3rem .65rem;
  border: 1px solid var(--border);
  border-radius: 99px;
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
}
.exemples button:hover { border-color: var(--accent); color: var(--accent); }

.checkbox-line { display: flex; align-items: center; gap: .45rem; font-size: .85rem; color: var(--text-muted); margin-bottom: .9rem; }
.checkbox-line input { width: auto; margin: 0; }

/* ── Résultats / tableaux ───────────────────────────────────────────── */

.resultats { margin-top: 1.2rem; }
.resultats .card { overflow-x: auto; }

table.dataframe, .resultats table {
  border-collapse: collapse;
  width: 100%;
  font-size: .82rem;
  background: var(--surface);
}
.resultats th {
  text-align: left;
  padding: .5rem .7rem;
  border-bottom: 2px solid var(--border);
  color: var(--text-muted);
  font-weight: 600;
  white-space: nowrap;
}
.resultats td { padding: .42rem .7rem; border-bottom: 1px solid var(--border); }
.resultats tr:hover td { background: #f8fafc; }

pre.sql {
  background: #0f172a;
  color: #e2e8f0;
  padding: .85rem 1rem;
  border-radius: 6px;
  font-size: .8rem;
  overflow-x: auto;
}

.note-erreur {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: var(--danger);
  border-radius: 6px;
  padding: .7rem .9rem;
  font-size: .87rem;
}

.badge { display: inline-block; padding: .15rem .55rem; border-radius: 99px; font-size: .75rem; font-weight: 600; }
.badge-ok  { background: #f0fdf4; color: var(--ok); border: 1px solid #bbf7d0; }
.badge-err { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; }

.muted { color: var(--text-muted); font-size: .85rem; }

iframe.dashboard {
  width: 100%;
  height: 800px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

/* Indicateur HTMX */
.htmx-indicator { display: none; color: var(--text-muted); font-size: .87rem; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: block; }

/* ── Page de connexion ──────────────────────────────────────────────── */

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}
.login-card {
  width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 2rem 2.2rem 1.8rem;
  box-shadow: 0 4px 24px rgba(15, 23, 42, .06);
}
.login-card .brand { border: none; padding: 0 0 1.3rem; }
.login-card .brand strong { color: var(--text); }
.login-card .brand small  { color: var(--text-muted); }
.login-card .btn { width: 100%; justify-content: center; }

/* ── Responsive ─────────────────────────────────────────────────────── */

@media (max-width: 760px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; }
  .sidebar nav { display: flex; flex-wrap: wrap; padding: .4rem; }
  .nav-section { display: none; }
  .content { padding: 1.2rem; }
}
