/* ===================================================================
   Cabinet Maître Hossou — Lexia IA — v2 with data extraction
=================================================================== */

:root {
  --ink: #0F1B2D;
  --ink-2: #1A2740;
  --ink-3: #2C3852;
  --ink-soft: #5A6577;
  --paper: #FAF7F2;
  --paper-2: #F0EBE0;
  --paper-3: #E5DECF;
  --line: #D8D0BD;
  --gold: #B89968;
  --gold-deep: #8C6E3F;
  --green: #5DA781;
  --green-soft: #E8F0EB;
  --orange: #C97B36;
  --orange-soft: #F8ECDA;
  --red: #B23A3A;
  --red-soft: #F5DDDD;
  --blue: #3B6E8C;
  --blue-soft: #DCE9EF;
  --shadow-sm: 0 1px 2px rgba(15, 27, 45, 0.04), 0 1px 3px rgba(15, 27, 45, 0.06);
  --shadow-md: 0 4px 16px rgba(15, 27, 45, 0.08), 0 2px 4px rgba(15, 27, 45, 0.04);
  --shadow-lg: 0 16px 40px rgba(15, 27, 45, 0.10), 0 4px 8px rgba(15, 27, 45, 0.06);
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;
  --serif: "Fraunces", "Cormorant Garamond", Georgia, serif;
  --sans: "DM Sans", -apple-system, system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--paper);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* ============================ LOGIN ============================ */

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  position: relative;
  background: var(--ink);
  overflow: hidden;
}

.login-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 70% 20%, rgba(184, 153, 104, 0.12), transparent 60%),
    radial-gradient(ellipse 60% 50% at 20% 80%, rgba(93, 167, 129, 0.08), transparent 60%),
    linear-gradient(135deg, #0F1B2D 0%, #1A2740 100%);
  pointer-events: none;
}

.login-shell {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 460px;
  padding: 24px;
}

.login-card {
  background: var(--paper);
  border-radius: var(--r-lg);
  padding: 44px 40px 32px;
  box-shadow: var(--shadow-lg);
  position: relative;
}
.login-card::before {
  content: "";
  position: absolute;
  top: 0; left: 50%;
  transform: translateX(-50%);
  width: 60px; height: 3px;
  background: var(--gold);
  border-radius: 0 0 3px 3px;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 36px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line);
}

.brand-mark {
  width: 52px; height: 52px;
  display: grid;
  place-items: center;
  font-family: var(--serif);
  font-weight: 600;
  font-size: 22px;
  background: var(--ink);
  color: var(--gold);
  border-radius: 8px;
  flex-shrink: 0;
}
.brand-mark.sm { width: 38px; height: 38px; font-size: 16px; border-radius: 6px; }

.brand-title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 19px;
  margin: 0;
  letter-spacing: -0.01em;
}
.brand-sub {
  font-size: 12.5px;
  color: var(--ink-soft);
  margin: 2px 0 0;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.login-step { display: none; animation: fadeStep 0.35s ease; }
.login-step.active { display: block; }
@keyframes fadeStep {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.login-step h2 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 26px;
  margin: 0 0 6px;
  letter-spacing: -0.015em;
}
.step-hint { font-size: 13.5px; color: var(--ink-soft); margin: 0 0 24px; }

label { display: block; margin-bottom: 16px; }
label > span {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  margin-bottom: 6px;
}
input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
.filter-select {
  width: 100%;
  padding: 12px 14px;
  font-family: var(--sans);
  font-size: 15px;
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--ink);
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, .filter-select:focus {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(15, 27, 45, 0.08);
}

.btn-primary {
  width: 100%;
  padding: 13px 20px;
  font-family: var(--sans);
  font-weight: 600;
  font-size: 14.5px;
  background: var(--ink);
  color: var(--paper);
  border: 0;
  border-radius: var(--r-sm);
  position: relative;
  transition: transform 0.1s, background 0.15s;
  margin-top: 8px;
}
.btn-primary:hover { background: var(--ink-2); }
.btn-primary:active { transform: scale(0.99); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-primary .btn-spinner {
  display: none;
  width: 14px; height: 14px;
  border: 2px solid rgba(250, 247, 242, 0.3);
  border-top-color: var(--paper);
  border-radius: 50%;
  margin-left: 10px;
  vertical-align: -2px;
  animation: spin 0.7s linear infinite;
}
.btn-primary.loading .btn-spinner { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

.btn-ghost {
  display: block;
  width: 100%;
  text-align: center;
  margin-top: 14px;
  padding: 10px;
  background: transparent;
  border: 0;
  color: var(--ink-soft);
  font-size: 13.5px;
}
.btn-ghost:hover { color: var(--ink); }

.form-error {
  font-size: 13px;
  color: var(--red);
  min-height: 18px;
  margin: 4px 0 8px;
}

.otp-inputs {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  margin: 12px 0;
}
.otp-inputs input {
  text-align: center;
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 500;
  padding: 14px 0;
}

.login-footer {
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  text-align: center;
  font-size: 11.5px;
  color: var(--ink-soft);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ============================ APP SHELL ============================ */

.app-body {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--ink);
  color: var(--paper);
  padding: 28px 18px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 6px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.sidebar-name {
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 500;
}
.sidebar-sub {
  font-size: 11px;
  color: rgba(250, 247, 242, 0.5);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-top: 2px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--r-sm);
  font-size: 14px;
  color: rgba(250, 247, 242, 0.75);
  transition: background 0.12s, color 0.12s;
}
.nav-item:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--paper);
}
.nav-item.active {
  background: rgba(184, 153, 104, 0.14);
  color: var(--gold);
}

.sidebar-foot {
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.user-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px;
  margin-bottom: 10px;
}
.user-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-deep) 100%);
  flex-shrink: 0;
}
.user-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--paper);
}
.user-email {
  font-size: 11.5px;
  color: rgba(250, 247, 242, 0.5);
}
.logout-btn {
  width: 100%;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(250, 247, 242, 0.7);
  padding: 9px;
  border-radius: var(--r-sm);
  font-size: 13px;
  transition: border-color 0.12s, color 0.12s;
}
.logout-btn:hover {
  border-color: rgba(255, 255, 255, 0.2);
  color: var(--paper);
}

.main {
  padding: 36px 44px 60px;
  max-width: 1400px;
  width: 100%;
}

.main-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line);
}
.eyebrow {
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0 0 6px;
  font-weight: 500;
}
.main-head h1 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 36px;
  letter-spacing: -0.02em;
  margin: 0;
}
.head-actions input[type="search"] { width: 320px; }

/* ============================ STATS ============================ */

.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 36px;
}
.stat-card {
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.stat-card-urgent {
  background: linear-gradient(135deg, rgba(178, 58, 58, 0.04), rgba(178, 58, 58, 0.01));
  border-color: rgba(178, 58, 58, 0.2);
}
.stat-label {
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  font-weight: 500;
}
.stat-value {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 30px;
  letter-spacing: -0.02em;
  color: var(--ink);
}

/* ============================ FILTERS ============================ */

.conv-section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 18px;
}
.conv-section-head h2 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 22px;
  margin: 0;
  letter-spacing: -0.01em;
  flex-shrink: 0;
  padding-top: 18px;
}

.filter-cluster {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  align-items: flex-start;
}
.filter-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.filter-group-label {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
}

.filter-tabs {
  display: flex;
  gap: 4px;
  background: var(--paper-2);
  padding: 4px;
  border-radius: var(--r-sm);
}
.filter-tabs .tab {
  padding: 6px 12px;
  background: transparent;
  border: 0;
  border-radius: 4px;
  font-size: 12.5px;
  color: var(--ink-soft);
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.filter-tabs .tab:hover { color: var(--ink); }
.filter-tabs .tab.active {
  background: white;
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}
.filter-tabs .tab.tab-haute.active { color: var(--red); }
.filter-tabs .tab.tab-moyenne.active { color: var(--orange); }
.filter-tabs .tab.tab-faible.active { color: var(--green); }

.filter-select {
  width: auto;
  min-width: 180px;
  padding: 8px 12px;
  font-size: 13px;
}

/* ============================ CONVERSATION CARDS ============================ */

.conv-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.conv-card {
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 18px;
  align-items: center;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
  position: relative;
  overflow: hidden;
}
.conv-card:hover {
  border-color: var(--ink-3);
  box-shadow: var(--shadow-md);
}
.conv-card:active { transform: scale(0.998); }

.conv-card.urgent {
  border-color: rgba(178, 58, 58, 0.3);
}
.conv-card.urgent:hover {
  border-color: var(--red);
}
.urgency-stripe {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--red);
}

.conv-card-inner {
  padding: 16px 20px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.conv-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}
.conv-card-title {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.conv-name {
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.01em;
  line-height: 1.2;
}
.conv-phone {
  font-size: 12.5px;
  color: var(--ink-soft);
}
.conv-phone .tel-link {
  color: var(--blue);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}
.conv-phone .tel-link:hover { text-decoration: underline; }

.conv-card-time {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 12px;
  color: var(--ink-soft);
  white-space: nowrap;
  flex-shrink: 0;
}
.conv-meta-dot {
  width: 3px; height: 3px;
  border-radius: 50%;
  background: var(--ink-soft);
}

.conv-card-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.conv-card-summary {
  font-size: 13.5px;
  color: var(--ink-2);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.conv-summary-empty {
  color: var(--ink-soft);
  font-style: italic;
}

.conv-card-creneau {
  font-size: 12.5px;
  color: var(--ink-soft);
  padding: 6px 10px;
  background: var(--paper-2);
  border-radius: 4px;
  margin-top: 2px;
}
.conv-card-creneau strong {
  color: var(--ink);
  font-weight: 600;
}

.conv-arrow {
  color: var(--ink-soft);
  font-size: 18px;
  padding-right: 16px;
}

/* ============================ BADGES ============================ */

.badge {
  display: inline-flex;
  align-items: center;
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 100px;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.badge-urgence-haute {
  background: var(--red-soft);
  color: var(--red);
}
.badge-urgence-moyenne {
  background: var(--orange-soft);
  color: var(--orange);
}
.badge-urgence-faible {
  background: var(--green-soft);
  color: var(--green);
}
.badge-matiere {
  background: var(--blue-soft);
  color: var(--blue);
}
.badge-rappel {
  background: rgba(184, 153, 104, 0.15);
  color: var(--gold-deep);
}

.badge-matiere-strong {
  font-size: 13px;
  padding: 5px 12px;
}
.badge-urgence-strong {
  font-size: 13px;
  padding: 5px 12px;
}

/* ============================ EMPTY / PAGINATION ============================ */

.empty {
  padding: 60px 20px;
  text-align: center;
  color: var(--ink-soft);
  font-size: 14px;
}

.pagination {
  margin-top: 24px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  font-size: 13.5px;
  color: var(--ink-soft);
}
.pagination button {
  background: white;
  border: 1px solid var(--line);
  padding: 7px 14px;
  border-radius: var(--r-sm);
  font-size: 13px;
  color: var(--ink);
}
.pagination button:hover:not(:disabled) { border-color: var(--ink-3); }
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }

/* ============================ CONVERSATION DETAIL ============================ */

.status-pill {
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 100px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.status-pill.success {
  background: var(--green-soft);
  color: var(--green);
}
.status-pill.failure {
  background: var(--red-soft);
  color: var(--red);
}
.status-pill.neutral {
  background: var(--paper-2);
  color: var(--ink-soft);
}

/* DATA EXTRACTION PANEL */
.data-panel {
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 22px 26px;
  margin-bottom: 24px;
  border-top: 3px solid var(--gold);
}

.data-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px 28px;
}

.data-cell {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px dashed transparent;
  cursor: default;
}
.data-cell[title] {
  cursor: help;
}

.data-icon {
  font-size: 18px;
  flex-shrink: 0;
  width: 28px;
  text-align: center;
  line-height: 1;
  padding-top: 2px;
}

.data-content {
  min-width: 0;
  flex: 1;
}

.data-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  margin-bottom: 4px;
}

.data-value {
  font-size: 15px;
  color: var(--ink);
  line-height: 1.4;
  word-break: break-word;
}

.data-value .muted, .data-cell.empty .data-value {
  color: var(--ink-soft);
  font-style: italic;
}

.tel-link-strong {
  color: var(--blue);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  font-size: 16px;
  letter-spacing: 0.02em;
}
.tel-link-strong:hover { text-decoration: underline; }

.bool-yes { color: var(--green); font-weight: 600; }
.bool-no { color: var(--ink-soft); }

/* SUMMARY + TRANSCRIPT GRID */
.conv-detail-grid {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 24px;
}

.conv-summary-panel,
.conv-transcript-panel {
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 22px 26px;
}

.panel-title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 18px;
  margin: 0 0 14px;
  letter-spacing: -0.01em;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.panel-subtitle {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
  font-weight: 600;
  margin: 26px 0 12px;
}

.summary-content {
  font-size: 14.5px;
  line-height: 1.65;
  color: var(--ink-2);
}
.summary-content.empty {
  color: var(--ink-soft);
  font-style: italic;
}

.meta-list {
  margin: 0;
  display: grid;
  gap: 10px;
}
.meta-list dt {
  font-size: 11px;
  color: var(--ink-soft);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 500;
}
.meta-list dd {
  margin: 2px 0 0;
  font-size: 13.5px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  word-break: break-all;
}

/* TRANSCRIPT */
.transcript {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 70vh;
  overflow-y: auto;
  padding-right: 6px;
}
.turn {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.turn-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 600;
  color: white;
}
.turn.agent .turn-avatar {
  background: linear-gradient(135deg, var(--ink-2) 0%, var(--ink) 100%);
}
.turn.user .turn-avatar {
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-deep) 100%);
}
.turn-body {
  flex: 1;
  background: var(--paper-2);
  padding: 10px 14px;
  border-radius: var(--r-sm);
  font-size: 14px;
  line-height: 1.55;
}
.turn.agent .turn-body { background: white; border: 1px solid var(--line); }
.turn-role {
  font-size: 10.5px;
  color: var(--ink-soft);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.turn-time {
  font-size: 10.5px;
  color: var(--ink-soft);
  margin-left: 8px;
  font-weight: 500;
}

@media (max-width: 1100px) {
  .data-grid { grid-template-columns: repeat(2, 1fr); }
  .conv-detail-grid { grid-template-columns: 1fr; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 720px) {
  .app-body { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    padding: 14px 18px;
  }
  .sidebar-nav { display: none; }
  .sidebar-foot { display: none; }
  .main { padding: 20px; }
  .stats-row { grid-template-columns: 1fr 1fr; }
  .head-actions input[type="search"] { width: 200px; }
  .data-grid { grid-template-columns: 1fr; }
  .conv-card-head { flex-direction: column; gap: 6px; }
}
