/* IAltesia OS web app — styling on the altesia.be brand
   (clean B2B consulting look: white background, Altesia orange primary, dark slate
   text, generous whitespace). Tune the palette variables below to match the brand. */

:root {
  /* Altesia brand palette (from altesia.be) */
  --altesia-orange: #f08626;
  --altesia-orange-dark: #d88534;
  --altesia-green: #80b257;
  --altesia-red: #b42318;
  --altesia-blue: #2b87ff;
  --altesia-sky: #e9f7fe;
  --altesia-ink: #32373c;

  --primary: var(--altesia-orange);
  --primary-dark: var(--altesia-orange-dark);
  --navy: #14323b;
  --slate: #1f2a37;
  --slate-muted: #647084;
  --bg: #ffffff;
  --bg-soft: #f5f8f8;
  --border: #e3e9ec;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(20, 50, 59, 0.06), 0 8px 24px rgba(20, 50, 59, 0.06);
  --maxw: 1080px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  color: var(--slate);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.container {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 24px;
}

/* --- Header --------------------------------------------------------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 68px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 18px;
}

.brand-logo {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.logo-img {
  height: 26px;
  width: auto;
  display: block;
  transition: opacity 0.15s ease;
}

.brand-logo:hover .logo-img { opacity: 0.7; }

.brand-name {
  text-decoration: none;
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--navy);
  letter-spacing: -0.01em;
}

.brand-name:hover { color: var(--altesia-orange); }

.nav { display: flex; align-items: center; gap: 28px; }

.nav-link {
  text-decoration: none;
  color: var(--slate-muted);
  font-weight: 500;
  font-size: 0.95rem;
  transition: color 0.15s ease;
}

.nav-link:hover { color: var(--navy); }
.nav-link.active { color: var(--primary); }

/* --- Departments dropdown ------------------------------------------------- */
.nav-dropdown { position: relative; display: inline-flex; align-items: center; }

.nav-dropdown-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 0;
  background: transparent;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
}
.nav-dropdown.active > .nav-dropdown-toggle { color: var(--primary); }

.nav-caret { width: 14px; height: 14px; fill: currentColor; transition: transform 0.15s ease; }
.nav-dropdown:hover .nav-caret,
.nav-dropdown.open .nav-caret { transform: rotate(180deg); }

.nav-menu {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  min-width: 180px;
  display: flex;
  flex-direction: column;
  padding: 8px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(20, 50, 59, 0.14);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
  z-index: 40;
}
.nav-dropdown:hover .nav-menu,
.nav-dropdown:focus-within .nav-menu,
.nav-dropdown.open .nav-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.nav-menu-link {
  text-decoration: none;
  color: var(--slate);
  font-weight: 500;
  font-size: 0.92rem;
  padding: 8px 12px;
  border-radius: 8px;
  transition: background 0.12s ease, color 0.12s ease;
}
.nav-menu-link:hover { background: var(--bg-soft); color: var(--navy); }
.nav-menu-link.active { color: var(--primary); background: var(--bg-soft); }

/* --- Home (clickable tiles) ----------------------------------------------- */

.home {
  background: linear-gradient(180deg, var(--bg-soft) 0%, #fff 100%);
  padding: 80px 0;
}

.home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.home-section-title {
  margin: 0 0 18px;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--slate-muted);
}
.home-grid + .home-section-title { margin-top: 44px; }

/* --- Department / Agents page copy ---------------------------------------- */
.page-intro { font-size: 1.02rem; color: var(--slate); margin: 0 0 12px; max-width: 70ch; }
.page-points { margin: 0 0 16px; padding-left: 20px; color: var(--slate); }
.page-points li { margin: 4px 0; }

.agent-list { list-style: none; margin: 8px 0 0; padding: 0; }
.agent-list li {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 0;
  border-top: 1px solid var(--border);
}
.agent-list li:first-child { border-top: 0; }
.agent-name { font-weight: 600; color: var(--navy); }
.agent-role { color: var(--slate-muted); font-size: 0.92rem; }

/* --- Data department: chapter tabs ---------------------------------------- */
.data-chapters { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 14px; border-bottom: 1px solid var(--border); }
.data-chapter {
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--slate-muted);
  padding: 10px 18px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.12s ease, border-color 0.12s ease;
}
.data-chapter:hover { color: var(--navy); }
.data-chapter.active { color: var(--primary); border-bottom-color: var(--primary); }

.readonly-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 9px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--slate-muted);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 999px;
  vertical-align: middle;
}

/* --- Data department: table selector pills -------------------------------- */
.data-selector { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.data-tab {
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--slate);
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-soft);
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.data-tab:hover { border-color: var(--altesia-orange); color: var(--navy); }
.data-tab.active {
  color: #fff;
  background: var(--primary);
  border-color: var(--primary);
}

/* --- Dashboard stat cards (CRM / PMO) ------------------------------------- */
.crm-dashboard .stat-cards + .stat-cards { margin-top: 12px; }
.stat-cards { display: flex; flex-wrap: wrap; gap: 12px; }
.stat-card {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 110px;
  padding: 14px 16px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.stat-card-lead { background: #fff; border-color: var(--altesia-orange); }
.stat-card-sm { min-width: 92px; padding: 10px 12px; }
.stat-num { font-size: 1.5rem; font-weight: 700; color: var(--navy); line-height: 1.1; }
.stat-card-sm .stat-num { font-size: 1.2rem; }
.stat-label { font-size: 0.78rem; color: var(--slate-muted); }

/* --- Kanban board (CRM / PMO) --------------------------------------------- */
.kanban { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 6px; align-items: flex-start; }
.kanban-col {
  flex: 0 0 230px;
  display: flex;
  flex-direction: column;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-height: 560px;
}
.kanban-col.drop-target { border-color: var(--altesia-orange); background: #fff7ef; }
.kanban-col-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--navy);
  border-bottom: 1px solid var(--border);
}
.kanban-count {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--slate-muted);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 8px;
}
.kanban-col-body { display: flex; flex-direction: column; gap: 8px; padding: 10px; overflow-y: auto; min-height: 40px; }
.kanban-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  cursor: grab;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: border-color 0.12s ease, transform 0.08s ease;
}
.kanban-card:hover { border-color: var(--altesia-orange); }
.kanban-card.dragging { opacity: 0.5; }
.kanban-card-title { font-weight: 600; font-size: 0.9rem; color: var(--navy); }
/* Action-required flag: colour the lead title in the overview.
   low = green, medium = orange, high = red. */
.lead-action-low { color: var(--altesia-green); }
.lead-action-medium { color: var(--altesia-orange); }
.lead-action-high { color: var(--altesia-red); }
.kanban-card-meta { font-size: 0.78rem; color: var(--slate-muted); }
.kanban-card-tag {
  align-self: flex-start;
  font-size: 0.72rem;
  color: var(--slate-muted);
  background: var(--bg-soft);
  border-radius: 999px;
  padding: 1px 8px;
}

.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 28px;
  padding: 30px;
  min-height: 220px;
  overflow: hidden;
  isolation: isolate;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-decoration: none;
  color: var(--navy);
  transition: transform 0.12s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

/* A slim Altesia-orange accent bar along the top edge. */
.tile::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 4px;
  background: linear-gradient(90deg, var(--altesia-orange), var(--altesia-orange-dark));
  z-index: 2;
}

.tile:hover {
  transform: translateY(-3px);
  border-color: var(--altesia-orange);
  box-shadow: 0 1px 3px rgba(50, 55, 60, 0.08), 0 16px 36px rgba(240, 134, 38, 0.16);
}

.tile-deco {
  position: absolute;
  top: -10px;
  right: -8px;
  width: 200px;
  height: auto;
  z-index: -1;
  transition: transform 0.25s ease;
}

.tile:hover .tile-deco { transform: translate(-6px, 4px) rotate(-3deg); }

.tile-body { display: flex; flex-direction: column; gap: 7px; }

.tile-eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--altesia-orange);
}

.tile-title { font-size: 1.7rem; font-weight: 700; letter-spacing: -0.01em; }
.tile-sub { color: var(--slate-muted); font-size: 0.98rem; max-width: 30ch; }

.tile-cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--altesia-orange-dark);
}

.tile-chevron {
  width: 12px;
  height: 12px;
  fill: currentColor;
  transition: transform 0.18s ease;
}

.tile:hover .tile-chevron { transform: translateX(5px); }

/* --- Panel ---------------------------------------------------------------- */

.panel-section { padding: 40px 0 80px; }

.panel + .panel { margin-top: 24px; }

.panel {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.panel-head h2 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--navy);
}

.results { padding: 8px 24px 24px; }

/* --- Button --------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.05s ease;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled {
  opacity: 0.6;
  cursor: progress;
}

/* --- Results -------------------------------------------------------------- */

.muted { color: var(--slate-muted); }

.results-meta {
  margin: 12px 0 4px;
  font-size: 0.9rem;
  color: var(--slate-muted);
}

.schema-group { margin-top: 18px; }

.schema-group h3 {
  margin: 0 0 8px;
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--primary-dark);
}

.table-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
}

.table-list li {
  padding: 10px 14px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--slate);
}

.notice {
  margin: 12px 0;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 0.95rem;
}

.notice-error {
  background: #fdecec;
  border: 1px solid #f5c2c2;
  color: #9b2c2c;
}

.notice-empty {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--slate-muted);
}

.notice-success {
  background: #ecfdf3;
  border: 1px solid #b7ebc6;
  color: #1c6b3f;
}

.notice-info {
  background: var(--altesia-sky);
  border: 1px solid #bfe3f5;
  color: var(--navy);
}

/* --- vCard (.vcf) drop zone ------------------------------------------------ */

.vcf-drop-zone {
  margin: 12px 0;
  padding: 18px 16px;
  border: 2px dashed var(--border);
  border-radius: 8px;
  background: var(--bg-soft);
  color: var(--slate-muted);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.vcf-drop-zone p { margin: 0; }

.vcf-drop-zone:hover,
.vcf-drop-zone:focus-visible {
  border-color: var(--primary);
  outline: none;
}

.vcf-drop-zone.drag-active {
  border-color: var(--primary);
  background: #fff;
  color: var(--slate);
}

.link-btn {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: var(--primary-dark);
  text-decoration: underline;
  cursor: pointer;
}

/* --- Controls: selects, inputs, ghost button ------------------------------ */

.panel-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.select,
.input {
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--slate);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
}

.select:focus,
.input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(240, 134, 38, 0.18);
}

.select { min-width: 220px; }

.btn-ghost {
  background: transparent;
  color: var(--slate-muted);
  border-color: var(--border);
}

.btn-ghost:hover { color: var(--navy); background: var(--bg-soft); }

.btn-danger {
  background: #b42318;
  color: #fff;
}

.btn-danger:hover { background: #912018; }

.btn-compact {
  padding: 6px 10px;
  font-size: 0.82rem;
}

/* --- Search form ---------------------------------------------------------- */

.search-form { padding-top: 8px; }

.search-fields {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  margin: 16px 0;
}

.search-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.search-field-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--slate-muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.search-actions { display: flex; gap: 10px; }

/* --- Data table (read / search results) ----------------------------------- */

.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-top: 8px;
}

.data-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.9rem;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table th {
  position: sticky;
  top: 0;
  background: var(--bg-soft);
  font-weight: 600;
  color: var(--navy);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.82rem;
}

.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: var(--bg-soft); }

.data-table tfoot .data-table-total td {
  border-top: 2px solid var(--border);
  border-bottom: none;
  font-weight: 600;
  color: var(--navy);
  background: var(--bg-soft);
}

.cell-null { color: var(--slate-muted); text-align: center; }
.empty-row { text-align: center; color: var(--slate-muted); padding: 20px; }

/* --- CRM: open leads ------------------------------------------------------ */

.lead-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
  margin-top: 8px;
}

.lead-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.lead-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.lead-id {
  font-weight: 700;
  color: var(--navy);
  font-size: 1.05rem;
}

.lead-stage {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--primary-dark);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 12px;
  white-space: nowrap;
}

.lead-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.lead-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--slate-muted);
}

.lead-people { color: var(--slate); }

.lead-logs {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.lead-logs li {
  font-size: 0.92rem;
  color: var(--slate);
}

.lead-log-date {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.82rem;
  color: var(--slate-muted);
}

/* --- Stakeholders -------------------------------------------------------- */

/* Single search bar in the table's panel head — fuzzy filter across any field. */
.stakeholders-search {
  flex: 1 1 auto;
  max-width: 360px;
}

/* Fiche modal overlay (opened from a row's View button). */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 6vh 20px 20px;
  background: rgba(15, 23, 42, 0.5);
  overflow-y: auto;
}

.modal-overlay[hidden] { display: none; }

body.modal-open { overflow: hidden; }

.modal-dialog {
  width: 100%;
  max-width: 720px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.25);
  overflow: hidden;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.modal-head h2 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--navy);
}

.modal-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-close {
  border: none;
  background: transparent;
  color: var(--slate-muted);
  font-size: 1.6rem;
  line-height: 1;
  padding: 0 4px;
  cursor: pointer;
}

.modal-close:hover { color: var(--navy); }

.modal-body { max-height: 70vh; overflow-y: auto; }

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
  padding-top: 8px;
}

.detail-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.detail-field-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--slate-muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.detail-value {
  min-height: 42px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-soft);
  color: var(--slate);
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}
a.detail-link {
  display: block;
  color: var(--primary-dark);
  text-decoration: none;
  font-weight: 500;
}
a.detail-link:hover { text-decoration: underline; border-color: var(--primary); }

.detail-input {
  width: 100%;
  min-height: 42px;
  resize: vertical;
  line-height: 1.45;
}

/* --- Assistant: stand-out nav entry + feature tile ------------------------ */

.nav-cta {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #fff;
  background: var(--primary);
  padding: 7px 15px;
  border-radius: 999px;
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(20, 50, 59, 0.12);
}

.nav-cta:hover { color: #fff; background: var(--primary-dark); }
.nav-cta.active { color: #fff; }

.nav-cta-icon {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

/* Feature tile (Assistant) — filled accent so it stands out among the tiles. */
.tile-feature {
  background: linear-gradient(150deg, var(--primary) 0%, var(--primary-dark) 100%);
  border-color: transparent;
}

.tile-feature .tile-eyebrow { color: rgba(255, 255, 255, 0.82); }
.tile-feature .tile-title { color: #fff; }
.tile-feature .tile-sub { color: rgba(255, 255, 255, 0.9); }
.tile-feature .tile-cta { color: #fff; }
.tile-feature .tile-chevron { fill: #fff; }

/* --- Assistant: chat panel ------------------------------------------------ */

.chat-panel {
  display: flex;
  flex-direction: column;
}

.chat-log {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px 24px;
  height: 56vh;
  min-height: 320px;
  overflow-y: auto;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--bg-soft);
}

.chat-empty { margin: auto; text-align: center; }

.chat-msg {
  display: flex;
  max-width: 100%;
}

.chat-msg-user { justify-content: flex-end; }
.chat-msg-assistant,
.chat-msg-error { justify-content: flex-start; }

.chat-bubble {
  max-width: 78%;
  padding: 11px 15px;
  border-radius: 14px;
  font-size: 0.96rem;
  line-height: 1.55;
  white-space: normal;
  overflow-wrap: anywhere;
}

.chat-msg-user .chat-bubble {
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-msg-assistant .chat-bubble {
  background: #fff;
  color: var(--slate);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.chat-msg-error .chat-bubble {
  background: #fdecec;
  color: #9b2c2c;
  border: 1px solid #f5c2c2;
  border-bottom-left-radius: 4px;
}

/* Typing indicator (assistant is thinking). */
.chat-typing {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.chat-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--slate-muted);
  opacity: 0.5;
  animation: chat-bounce 1.2s infinite ease-in-out both;
}

.chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.chat-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes chat-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-4px); opacity: 0.9; }
}

.chat-composer {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 16px 24px 20px;
}

/* The Send button matches the message field's height exactly (grows with it). */
#chat-send-btn { align-self: stretch; }

.chat-input {
  flex: 1;
  resize: none;
  font-family: inherit;
  font-size: 0.96rem;
  line-height: 1.5;
  color: var(--slate);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 14px;
  max-height: 160px;
  overflow-y: auto;
}

.chat-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(240, 134, 38, 0.18);
}

/* --- Footer --------------------------------------------------------------- */

.site-footer {
  border-top: 1px solid var(--border);
  padding: 24px 0;
}

.site-footer .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
  color: var(--slate);
}

@media (max-width: 640px) {
  .tile-title { font-size: 1.25rem; }
  .header-inner {
    height: auto;
    min-height: 68px;
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
    padding-top: 14px;
    padding-bottom: 14px;
  }
  .nav {
    width: 100%;
    gap: 10px;
    flex-wrap: wrap;
  }
  .nav-link { font-size: 0.88rem; }
  .panel-head { flex-direction: column; align-items: flex-start; }
  .select { min-width: 0; width: 100%; }
  .chat-bubble { max-width: 88%; }
  .chat-log { height: 60vh; padding: 16px; }
  .chat-composer { padding: 12px 16px 16px; }
}

/* --- Searchable combobox (related-entity pickers in a fiche) --------------- */
.fiche-combo { position: relative; }
.fiche-combo-list {
  position: absolute;
  z-index: 20;
  left: 0;
  right: 0;
  margin: 2px 0 0;
  padding: 4px 0;
  list-style: none;
  max-height: 220px;
  overflow-y: auto;
  background: var(--bg, #fff);
  border: 1px solid var(--border, #e3e9ec);
  border-radius: var(--radius, 10px);
  box-shadow: 0 8px 24px rgba(20, 50, 59, 0.12);
}
.fiche-combo-item { padding: 0.4rem 0.6rem; cursor: pointer; }
.fiche-combo-item:hover { background: var(--bg-soft, #f5f8f8); }

/* --- Fiche link sections (logs / leads many-to-many) ---------------------- */
.fiche-section { margin-top: 18px; }
.fiche-section > h3 {
  margin: 0 0 8px;
  font-size: 0.95rem;
  color: var(--navy, #14323b);
}
.fiche-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.fiche-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--bg-soft, #f5f8f8);
  border: 1px solid var(--border, #e3e9ec);
  border-radius: 999px;
  font-size: 0.85rem;
}
.fiche-chip button {
  border: 0;
  background: transparent;
  cursor: pointer;
  color: var(--slate-muted, #647084);
  font-size: 1rem;
  line-height: 1;
}
.fiche-timeline { list-style: none; margin: 0; padding: 0; }
.fiche-timeline li {
  padding: 8px 0;
  border-bottom: 1px solid var(--border, #e3e9ec);
}
.fiche-timeline .lead-log-date { color: var(--slate-muted, #647084); margin-right: 6px; }
.lead-log-link { text-decoration: none; cursor: pointer; }
.lead-log-link:hover { text-decoration: underline; color: var(--accent, #2563eb); }

/* IT department — Q&A accordion (native <details>/<summary>) ---------------- */
.faq { margin-top: 8px; }
.faq-item {
  border-bottom: 1px solid var(--border, #e3e9ec);
}
.faq-item:first-child { border-top: 1px solid var(--border, #e3e9ec); }
.faq-item > summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 4px;
  cursor: pointer;
  list-style: none;            /* hide the default disclosure marker */
  font-weight: 600;
  color: var(--slate, #1f2a37);
}
.faq-item > summary::-webkit-details-marker { display: none; }
.faq-item > summary::before {
  content: "";
  flex: none;
  width: 0;
  height: 0;
  border-left: 6px solid currentColor;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  transition: transform 0.15s ease;
  color: var(--slate-muted, #647084);
}
.faq-item[open] > summary { color: var(--primary, #f08626); }
.faq-item[open] > summary::before { transform: rotate(90deg); }
.faq-item > summary:hover { color: var(--primary, #f08626); }
.faq-body {
  padding: 0 4px 16px 24px;
  color: var(--slate, #1f2a37);
  max-width: 72ch;
}
.faq-body p { margin: 0 0 10px; }
.faq-body code {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.88em;
  padding: 1px 5px;
  background: var(--bg-soft, #f5f8f8);
  border: 1px solid var(--border, #e3e9ec);
  border-radius: 6px;
}

/* --- Accounts: navbar state + login page ---------------------------------- */

.nav-user {
  color: var(--slate-muted);
  font-size: 0.88rem;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-logout-form { display: inline; margin: 0; }

.nav-logout {
  background: none;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 12px;
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--slate-muted);
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.nav-logout:hover { color: var(--altesia-red); border-color: var(--altesia-red); }

.auth-wrap { padding: 72px 0; }

.auth-card {
  max-width: 420px;
  margin: 0 auto;
  background: linear-gradient(180deg, var(--bg-soft) 0%, #fff 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 36px 32px;
}

.auth-eyebrow {
  margin: 0 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--primary);
}

.auth-title { margin: 0 0 8px; color: var(--navy); font-size: 1.6rem; }

.auth-sub { margin: 0 0 20px; color: var(--slate-muted); font-size: 0.95rem; }

.auth-error {
  margin: 0 0 16px;
  padding: 10px 12px;
  border: 1px solid var(--altesia-red);
  border-radius: var(--radius);
  background: #fdf0ef;
  color: var(--altesia-red);
  font-size: 0.9rem;
}

.auth-label {
  display: block;
  margin: 14px 0 6px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--slate);
}

.auth-input {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 0.95rem;
  color: var(--slate);
  background: var(--bg);
}
.auth-input:focus { outline: 2px solid var(--primary); outline-offset: 0; border-color: var(--primary); }

.auth-submit {
  width: 100%;
  margin-top: 20px;
  padding: 11px 16px;
  border: none;
  border-radius: var(--radius);
  background: var(--primary);
  color: #fff;
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}
.auth-submit:hover { background: var(--primary-dark); }
