/* iAtout.io — outils internes (Documents RAG + Billets) */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: var(--sans);
  color: var(--cream);
  background: var(--night-deep);
  background-image: var(--grad-night);
  background-attachment: fixed;
  min-height: 100%;
}
a { color: inherit; }
button { font-family: inherit; }

.app-shell { min-height: 100vh; display: flex; flex-direction: column; }

/* ─── Top bar ─────────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; gap: 24px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(7, 9, 15, 0.7);
  backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 20;
}
.brand { font-family: var(--mono); letter-spacing: 0.22em; text-transform: uppercase; font-size: 12px; color: var(--muted); text-decoration: none; }
.brand .star { color: var(--gold); }
.nav { display: flex; gap: 6px; margin-left: 8px; }
.nav a {
  text-decoration: none; color: var(--muted);
  font-size: 14px; padding: 8px 14px; border-radius: 999px;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav a:hover { color: var(--cream); }
.nav a.active { color: var(--night-deep); background: var(--grad-signature); font-weight: 500; }
.spacer { flex: 1; }
.who { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }
.who img { width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--line-strong); }
.linkbtn { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 13px; text-decoration: underline; }
.linkbtn:hover { color: var(--cream); }

/* ─── Layout ──────────────────────────────────────────────── */
.page { flex: 1; max-width: 1080px; width: 100%; margin: 0 auto; padding: 28px 24px 60px; }
.page-head { margin-bottom: 24px; }
.page-head h1 { font-family: var(--display); font-weight: 500; font-size: 30px; letter-spacing: -0.01em; }
.page-head p { color: var(--muted); font-size: 15px; margin-top: 6px; }

.card {
  background: rgba(17, 22, 42, 0.55);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 22px;
}

/* ─── Tool home cards ─────────────────────────────────────── */
.tool-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px; }
.tool-card {
  display: block; text-decoration: none;
  background: rgba(17, 22, 42, 0.55);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 26px;
  transition: transform 0.18s ease, border-color 0.18s ease;
}
.tool-card:hover { transform: translateY(-3px); border-color: var(--line-strong); }
.tool-card .ic { font-size: 26px; margin-bottom: 14px; }
.tool-card h3 { font-family: var(--display); font-weight: 500; font-size: 21px; margin-bottom: 6px; }
.tool-card p { color: var(--muted); font-size: 14px; line-height: 1.5; }

/* ─── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  border: none; border-radius: 999px;
  padding: 11px 20px; font-size: 14px; font-weight: 500;
  color: var(--night-deep); background: var(--grad-signature);
  transition: transform 0.15s ease, opacity 0.15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-ghost {
  color: var(--cream); background: transparent;
  border: 1px solid var(--line-strong);
}
.btn-sm { padding: 7px 14px; font-size: 13px; }
.btn-danger { color: var(--gold-soft); background: transparent; border: 1px solid rgba(212,165,116,0.4); }

/* ─── Forms ───────────────────────────────────────────────── */
label.field { display: block; margin-bottom: 14px; }
label.field span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
input[type=text], textarea, select {
  width: 100%; font-family: var(--sans); font-size: 15px;
  color: var(--cream); background: rgba(7,9,15,0.5);
  border: 1px solid var(--line-strong); border-radius: var(--r-md);
  padding: 11px 14px;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--teal); }
textarea { resize: vertical; min-height: 90px; line-height: 1.5; }
select option { background: var(--night-soft); }

/* ─── Documents list ──────────────────────────────────────── */
.doc-list { display: flex; flex-direction: column; gap: 12px; margin-top: 18px; }
.doc-item {
  display: flex; align-items: flex-start; gap: 14px;
  background: rgba(17, 22, 42, 0.5);
  border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 16px 18px;
}
.doc-item .doc-ic {
  flex-shrink: 0; width: 38px; height: 38px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(125,211,192,0.12); color: var(--teal);
  font-family: var(--mono); font-size: 11px; text-transform: uppercase; font-weight: 600;
}
.doc-main { flex: 1; min-width: 0; }
.doc-name { font-weight: 500; font-size: 15px; word-break: break-word; }
.doc-link { display: inline-block; text-decoration: none; color: var(--cream); transition: color 0.15s ease; }
.doc-link:hover { color: var(--teal); text-decoration: underline; }
.doc-resume { color: var(--muted); font-size: 13.5px; margin-top: 4px; line-height: 1.5; font-style: italic; }
.doc-meta { color: var(--muted-soft); font-family: var(--mono); font-size: 11px; margin-top: 6px; }
.doc-pending { color: var(--muted-soft); font-size: 13px; margin-top: 4px; }

.dropzone {
  border: 1.5px dashed var(--line-strong); border-radius: var(--r-md);
  padding: 28px; text-align: center; color: var(--muted);
  cursor: pointer; transition: border-color 0.15s ease, background 0.15s ease;
}
.dropzone:hover, .dropzone.drag { border-color: var(--teal); background: rgba(125,211,192,0.05); }

/* ─── Chat box ────────────────────────────────────────────── */
.chat-wrap {
  margin-top: 26px;
  background: rgba(10, 14, 26, 0.7);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-xl);
  overflow: hidden;
  display: flex; flex-direction: column;
  min-height: 460px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.45);
}
.chat-head {
  padding: 16px 22px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px;
  background: linear-gradient(180deg, rgba(155,126,189,0.10), transparent);
}
.chat-head .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--teal); box-shadow: 0 0 12px var(--teal); }
.chat-head h3 { font-family: var(--display); font-weight: 500; font-size: 18px; }
.chat-head .sub { color: var(--muted); font-size: 12px; margin-left: auto; }
.chat-log { flex: 1; overflow-y: auto; padding: 22px; display: flex; flex-direction: column; gap: 18px; }
.chat-empty { margin: auto; text-align: center; color: var(--muted); max-width: 360px; }
.chat-empty .big { font-size: 30px; margin-bottom: 12px; }
.msg { display: flex; gap: 12px; max-width: 88%; }
.msg.user { align-self: flex-end; flex-direction: row-reverse; }
.msg .av {
  flex-shrink: 0; width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-family: var(--mono);
}
.msg.user .av { background: var(--gold); color: var(--night-deep); }
.msg.bot .av { background: var(--grad-signature); color: var(--night-deep); }
.bubble {
  padding: 14px 18px; border-radius: 16px;
  font-size: 15px; line-height: 1.65;
}
.msg.user .bubble { background: rgba(212,165,116,0.14); border: 1px solid rgba(212,165,116,0.25); border-bottom-right-radius: 4px; }
.msg.bot .bubble { background: rgba(17,22,42,0.85); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
/* Markdown inside bot bubble */
.bubble h1, .bubble h2, .bubble h3 { font-family: var(--display); font-weight: 600; margin: 10px 0 6px; line-height: 1.25; }
.bubble h1 { font-size: 20px; } .bubble h2 { font-size: 18px; } .bubble h3 { font-size: 16px; }
.bubble p { margin: 8px 0; }
.bubble ul, .bubble ol { margin: 8px 0 8px 22px; }
.bubble li { margin: 3px 0; }
.bubble code { font-family: var(--mono); font-size: 13px; background: rgba(125,211,192,0.12); color: var(--teal); padding: 1px 6px; border-radius: 5px; }
.bubble pre { background: rgba(7,9,15,0.7); border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px 14px; overflow-x: auto; margin: 10px 0; }
.bubble pre code { background: none; color: var(--cream-soft); padding: 0; }
.bubble a { color: var(--teal); }
.bubble strong { color: var(--paper); }
.bubble :first-child { margin-top: 0; }
.bubble :last-child { margin-bottom: 0; }
.sources { margin-top: 8px; font-family: var(--mono); font-size: 11px; color: var(--muted-soft); }
.chat-input { display: flex; gap: 10px; padding: 16px 18px; border-top: 1px solid var(--line); background: rgba(7,9,15,0.5); }
.chat-input textarea { min-height: 46px; max-height: 160px; }
.typing { display: inline-flex; gap: 4px; }
.typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: 0.2s; } .typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 60%, 100% { opacity: 0.25; } 30% { opacity: 1; } }

/* ─── Tickets ─────────────────────────────────────────────── */
.tickets-grid { display: flex; flex-direction: column; gap: 14px; margin-top: 20px; }
.ticket {
  background: rgba(17, 22, 42, 0.5);
  border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 18px 20px;
}
.ticket-top { display: flex; align-items: flex-start; gap: 12px; }
.ticket h3 { font-size: 17px; font-weight: 500; flex: 1; }
.ticket .desc { color: var(--cream-soft); font-size: 14.5px; line-height: 1.55; margin-top: 8px; white-space: pre-wrap; }
.ticket-meta { display: flex; align-items: center; gap: 12px; margin-top: 12px; color: var(--muted-soft); font-family: var(--mono); font-size: 11px; }
.ticket-imgs { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.ticket-imgs img { max-height: 130px; border-radius: var(--r-md); border: 1px solid var(--line-strong); cursor: zoom-in; }
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-family: var(--mono); padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--line-strong);
}
.badge::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.ouvert { color: var(--teal); }
.badge.en_cours { color: var(--gold); }
.badge.ferme { color: var(--muted); }

.paste-zone {
  border: 1.5px dashed var(--line-strong); border-radius: var(--r-md);
  padding: 18px; text-align: center; color: var(--muted); font-size: 14px;
  margin-bottom: 12px; transition: border-color 0.15s ease, background 0.15s ease;
}
.paste-zone:focus { outline: none; border-color: var(--teal); background: rgba(125,211,192,0.05); }
.paste-zone.has { border-style: solid; }
.preview-imgs { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.preview-imgs .pi { position: relative; }
.preview-imgs img { max-height: 120px; border-radius: var(--r-md); border: 1px solid var(--line-strong); }
.preview-imgs .rm {
  position: absolute; top: -8px; right: -8px; width: 22px; height: 22px;
  border-radius: 50%; border: none; cursor: pointer;
  background: var(--gold); color: var(--night-deep); font-size: 14px; line-height: 1;
}

/* ─── Misc ────────────────────────────────────────────────── */
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.right { margin-left: auto; }
.muted { color: var(--muted); font-size: 14px; }
.empty { text-align: center; color: var(--muted); padding: 50px 20px; }
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--night-elev); border: 1px solid var(--line-strong);
  color: var(--cream); padding: 12px 20px; border-radius: 999px; font-size: 14px;
  z-index: 100; box-shadow: 0 12px 40px rgba(0,0,0,0.5);
}
.toast.err { border-color: rgba(212,165,116,0.5); color: var(--gold-soft); }

/* ─── Users (admin) ───────────────────────────────────────── */
.user-list { display: flex; flex-direction: column; gap: 12px; margin-top: 18px; }
.user-row {
  display: flex; align-items: center; gap: 14px;
  background: rgba(17, 22, 42, 0.5);
  border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 14px 18px;
}
.user-av { width: 42px; height: 42px; border-radius: 50%; flex-shrink: 0; border: 1px solid var(--line-strong); object-fit: cover; }
.user-av-ph { display: flex; align-items: center; justify-content: center; background: var(--grad-signature); color: var(--night-deep); font-weight: 600; font-family: var(--mono); }
.user-main { flex: 1; min-width: 0; }
.user-name { font-weight: 500; font-size: 15px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.user-mail { color: var(--cream-soft); font-size: 13.5px; margin-top: 2px; word-break: break-all; }
.user-meta { color: var(--muted-soft); font-family: var(--mono); font-size: 11px; margin-top: 5px; }
.tag { font-size: 11px; font-family: var(--mono); text-transform: uppercase; letter-spacing: 0.05em; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line-strong); color: var(--muted); }
.tag-gold { color: var(--gold); border-color: rgba(212,165,116,0.4); }

/* Switch */
.switch { position: relative; display: inline-block; width: 52px; height: 30px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; inset: 0; cursor: pointer;
  background: rgba(245,239,224,0.14); border-radius: 999px;
  transition: background 0.2s ease;
}
.slider::before {
  content: ''; position: absolute; height: 22px; width: 22px; left: 4px; top: 4px;
  background: var(--cream); border-radius: 50%; transition: transform 0.2s ease;
}
.switch input:checked + .slider { background: var(--grad-signature); }
.switch input:checked + .slider::before { transform: translateX(22px); }

.loading-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; color: var(--muted); font-family: var(--mono); letter-spacing: 0.15em; }

@media (max-width: 640px) {
  .nav a { padding: 7px 10px; font-size: 13px; }
  .who .name { display: none; }
  .msg { max-width: 96%; }
}
