/* ── Variables ───────────────────────────────────────────────────────────── */
:root {
  --bg:        #0e1117;
  --bg2:       #161b24;
  --bg3:       #1e2533;
  --border:    #2a3245;
  --text:      #c9d1e0;
  --text-dim:  #5a6a85;
  --text-head: #e8edf5;
  --accent:    #3b82f6;
  --accent-h:  #2563eb;
  --danger:    #ef4444;
  --success:   #22c55e;
  --warning:   #c9860a;
  --mono:      'IBM Plex Mono', monospace;
  --sans:      'IBM Plex Sans', sans-serif;
  --radius:    6px;
  --shadow:    0 4px 24px rgba(0,0,0,.4);
}

/* ── Reset ───────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.6;
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Auth layout ─────────────────────────────────────────────────────────── */
.auth-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
}

.auth-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2.5rem;
  width: 100%;
  max-width: 400px;
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: .6rem;
  margin-bottom: 2rem;
}
.auth-logo-mark {
  font-size: 1.5rem;
  color: var(--accent);
  line-height: 1;
}
.auth-logo-text {
  font-family: var(--mono);
  font-size: .9rem;
  color: var(--text-head);
  letter-spacing: .05em;
}

.auth-title {
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--text-head);
  margin-bottom: .3rem;
}
.auth-sub {
  color: var(--text-dim);
  font-size: .9rem;
  margin-bottom: 1.8rem;
}

.auth-form { display: flex; flex-direction: column; gap: 1.2rem; }

.auth-divider {
  text-align: center;
  position: relative;
  margin: 1.2rem 0;
  color: var(--text-dim);
  font-size: .85rem;
}
.auth-divider::before, .auth-divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 42%;
  height: 1px;
  background: var(--border);
}
.auth-divider::before { left: 0; }
.auth-divider::after  { right: 0; }

.auth-back {
  display: block;
  text-align: center;
  margin-top: 1.2rem;
  font-size: .85rem;
  color: var(--text-dim);
}
.auth-back:hover { color: var(--text); }

/* ── Form elements ───────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: .4rem; }
label {
  font-size: .82rem;
  font-weight: 500;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: .06em;
}
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="search"],
select,
textarea {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-head);
  font-family: var(--sans);
  font-size: .95rem;
  padding: .6rem .8rem;
  width: 100%;
  transition: border-color .15s;
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
}
input::placeholder { color: var(--text-dim); }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: var(--sans);
  font-size: .9rem;
  font-weight: 500;
  padding: .65rem 1.2rem;
  transition: background .15s, opacity .15s;
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  text-decoration: none;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-full { width: 100%; justify-content: center; }

.btn-primary  { background: var(--accent);  color: #fff; }
.btn-primary:hover  { background: var(--accent-h); text-decoration: none; }
.btn-secondary { background: var(--bg3); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--accent); color: var(--text-head); text-decoration: none; }
.btn-danger   { background: var(--danger);  color: #fff; }
.btn-danger:hover { opacity: .88; text-decoration: none; }
.btn-ghost    { background: transparent; color: var(--text-dim); }
.btn-ghost:hover { color: var(--text-head); text-decoration: none; }
.btn-sm { padding: .35rem .75rem; font-size: .82rem; }

/* ── Alerts ──────────────────────────────────────────────────────────────── */
.alert {
  border-radius: var(--radius);
  font-size: .88rem;
  padding: .7rem 1rem;
  margin-bottom: 1rem;
  border-left: 3px solid;
}
.alert-error   { background: rgba(239,68,68,.1);  border-color: var(--danger);  color: #fca5a5; }
.alert-success { background: rgba(34,197,94,.1);  border-color: var(--success); color: #86efac; }
.alert-info    { background: rgba(59,130,246,.1); border-color: var(--accent);  color: #93c5fd; }
.alert-warning { background: rgba(201,134,10,.1); border-color: var(--warning); color: #fbbf24; }

/* ── App shell ───────────────────────────────────────────────────────────── */
.app-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  grid-template-rows: auto 1fr;
  min-height: 100vh;
}

.topbar {
  grid-column: 1 / -1;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  height: 52px;
}
.topbar-brand {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-family: var(--mono);
  font-size: .85rem;
  color: var(--text-head);
}
.topbar-brand-mark { color: var(--accent); font-size: 1.2rem; }
.topbar-user {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: .85rem;
  color: var(--text-dim);
}

.sidebar {
  background: var(--bg2);
  border-right: 1px solid var(--border);
  padding: 1.2rem 0;
}
.sidebar-section {
  padding: .4rem 1rem .2rem;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--text-dim);
  font-weight: 500;
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .5rem 1.2rem;
  color: var(--text);
  font-size: .9rem;
  transition: background .1s, color .1s;
  border-left: 2px solid transparent;
}
.sidebar-link:hover { background: var(--bg3); color: var(--text-head); text-decoration: none; }
.sidebar-link.active {
  background: var(--bg3);
  color: var(--accent);
  border-left-color: var(--accent);
}

.main-content {
  padding: 1.8rem 2rem;
  overflow-y: auto;
}

/* ── Page header ─────────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.8rem;
}
.page-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-head);
}
.page-sub {
  font-size: .85rem;
  color: var(--text-dim);
  margin-top: .2rem;
  font-family: var(--mono);
}

/* ── Table ───────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
}
th {
  text-align: left;
  padding: .55rem .8rem;
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
  font-weight: 500;
}
td {
  padding: .6rem .8rem;
  border-bottom: 1px solid var(--border);
  font-family: var(--mono);
  font-size: .85rem;
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg3); }

/* ── Badges ──────────────────────────────────────────────────────────────── */
.badge {
  border-radius: 3px;
  font-family: var(--mono);
  font-size: .75rem;
  padding: .15rem .4rem;
  font-weight: 500;
  display: inline-block;
}
.badge-blue    { background: rgba(59,130,246,.15);  color: #93c5fd; }
.badge-green   { background: rgba(34,197,94,.15);   color: #86efac; }
.badge-gray    { background: rgba(90,106,133,.2);   color: var(--text-dim); }
.badge-red     { background: rgba(239,68,68,.15);   color: #fca5a5; }
.badge-orange  { background: rgba(201,134,10,.15);  color: #fbbf24; }

/* ── Card ────────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.2rem;
}
.card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-head);
}

/* ── Draft banner ────────────────────────────────────────────────────────── */
.draft-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .75rem 1rem;
  background: var(--bg2);
  border: 1px solid var(--warning);
  border-radius: var(--radius) var(--radius) 0 0;
  margin-bottom: 0;
  font-size: .9rem;
}

.draft-banner-left {
  display: flex;
  align-items: center;
  gap: .6rem;
}

.draft-banner-icon {
  font-size: 1rem;
  flex-shrink: 0;
}

.draft-banner-actions {
  display: flex;
  gap: .5rem;
  align-items: center;
  flex-shrink: 0;
}

/* Quand le bandeau est affiché, le détail (replié ou non) s'accroche dessous */
#draft-detail {
  background: var(--bg2);
  border: 1px solid var(--warning);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  padding: .8rem 1rem;
  margin-bottom: 1rem;
}

/* Quand pas de détail ouvert, ajouter le margin-bottom au bandeau lui-même */
.draft-banner:not(:has(+ #draft-detail[style*="block"])) {
  border-radius: var(--radius);
  margin-bottom: 1rem;
}

/* ── Modal ───────────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 100%; max-width: 520px;
  padding: 1.8rem;
}
.modal-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-head);
  margin-bottom: 1.2rem;
}
.modal-footer {
  display: flex;
  gap: .6rem;
  justify-content: flex-end;
  margin-top: 1.5rem;
}

/* ── HTMX indicators ─────────────────────────────────────────────────────── */
.htmx-indicator { opacity: 0; transition: opacity .2s; }
.htmx-request .htmx-indicator { opacity: 1; }
