/* ============================================================
   Le Chat Moine — app (dashboard coach, auth, admin)
   Design tokens alignés sur la landing (public/landing.css)
   ============================================================ */

:root {
  --sand: #FDF6EC;
  --sand-2: #F6E7D2;
  --ink: #173F3F;
  --ink-soft: #4E6E6B;
  --sea: #2EC4B6;
  --sea-deep: #1D9E92;
  --sea-light: #A8E6DC;
  --coral: #FF6B5E;
  --coral-deep: #EF5347;
  --sakura: #F7C8D8;
  --straw: #E9B44C;
  --white: #FFFFFF;

  --font-display: "Fraunces", "Noto Serif SC", Georgia, serif;
  --font-body: "Outfit", "Noto Sans SC", -apple-system, system-ui, sans-serif;

  --radius-lg: 28px;
  --radius-md: 16px;
  --shadow-soft: 0 20px 50px rgba(23, 63, 63, 0.10);
  --hairline: rgba(23, 63, 63, 0.10);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-body);
  background: var(--sand);
  color: var(--ink);
  line-height: 1.65;
  min-height: 100vh;
}

::selection { background: var(--coral); color: var(--white); }
img { max-width: 100%; display: block; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; line-height: 1.2; }

a { color: var(--sea-deep); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  padding: 0.8rem 1.5rem;
  border-radius: 999px;
  border: 2px solid transparent;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}
.btn:hover { transform: translateY(-2px); }
.btn-coral { background: var(--coral); color: var(--white); }
.btn-coral:hover { background: var(--coral-deep); }
.btn-ghost { background: transparent; border-color: rgba(23, 63, 63, 0.25); color: var(--ink); }
.btn-ghost:hover { border-color: var(--ink); background: rgba(255, 255, 255, 0.6); }
.btn-small { padding: 0.45rem 1rem; font-size: 0.85rem; }

.flash {
  max-width: 720px;
  margin: 1rem auto 0;
  padding: 0.8rem 1.2rem;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
}
.flash.notice { background: rgba(168, 230, 220, 0.45); color: var(--ink); }
.flash.alert { background: rgba(255, 107, 94, 0.14); color: var(--coral-deep); }

/* ---------- auth ---------- */

.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem 1rem;
  background:
    radial-gradient(60% 45% at 72% 18%, rgba(255, 214, 170, 0.5) 0%, rgba(255, 214, 170, 0) 70%),
    linear-gradient(180deg, var(--sand) 0%, #FCE9DC 40%, #F7C8D8 75%, #C9ECE4 100%);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--white);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  padding: 2.4rem 2.2rem;
  box-shadow: var(--shadow-soft);
}
.auth-card .brand { display: flex; align-items: center; gap: 0.65rem; margin-bottom: 1.4rem; text-decoration: none; color: var(--ink); }
.auth-card .brand img { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; border: 2px solid var(--sand-2); }
.auth-card .brand span { font-family: var(--font-display); font-weight: 700; font-size: 1.15rem; }
.auth-card h1 { font-size: 1.4rem; margin-bottom: 1.2rem; }
.auth-card p.hint { font-size: 0.85rem; color: var(--ink-soft); margin-top: 1.2rem; }

.field { margin-bottom: 1rem; }
.field label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 0.35rem; }
.field input, .field textarea {
  width: 100%;
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--ink);
  background: #FFFEFB;
  border: 1.5px solid rgba(23, 63, 63, 0.16);
  border-radius: 14px;
  padding: 0.8rem 1rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.field input:focus, .field textarea:focus {
  outline: none;
  border-color: var(--sea);
  box-shadow: 0 0 0 4px rgba(168, 230, 220, 0.45);
}
.field-err { color: var(--coral-deep); font-size: 0.82rem; margin-top: 0.3rem; }

/* ---------- dashboard coach ---------- */

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

.sidebar {
  background: var(--ink);
  color: var(--sand);
  display: flex;
  flex-direction: column;
  padding: 1.4rem 1.1rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar .brand { display: flex; align-items: center; gap: 0.6rem; text-decoration: none; color: var(--sand); margin-bottom: 1.4rem; }
.sidebar .brand img { width: 42px; height: 42px; border-radius: 50%; object-fit: cover; border: 2px solid var(--sea-light); }
.sidebar .brand span { font-family: var(--font-display); font-weight: 700; font-size: 1.1rem; }

.btn-new-session {
  background: var(--coral);
  color: var(--white);
  border: none;
  border-radius: 999px;
  padding: 0.8rem 1rem;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  width: 100%;
  margin-bottom: 1.4rem;
  transition: background 0.2s ease, transform 0.2s ease;
}
.btn-new-session:hover:not(:disabled) { background: var(--coral-deep); transform: translateY(-1px); }
.btn-new-session:disabled {
  background: rgba(253, 246, 236, 0.25);
  color: rgba(253, 246, 236, 0.55);
  cursor: not-allowed;
  transform: none;
}

.session-list { list-style: none; flex: 1; display: flex; flex-direction: column; gap: 0.35rem; }
.session-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.7rem;
  border-radius: 12px;
  color: rgba(253, 246, 236, 0.85);
  text-decoration: none;
  font-size: 0.88rem;
  transition: background 0.2s ease;
}
.session-item:hover { background: rgba(255, 255, 255, 0.08); }
.session-item.current { background: rgba(46, 196, 182, 0.22); color: var(--sand); }
.session-item .dot { width: 8px; height: 8px; border-radius: 50%; background: rgba(253, 246, 236, 0.35); flex-shrink: 0; }
.session-item.active .dot { background: var(--sea-light); box-shadow: 0 0 8px var(--sea-light); }
.session-item .s-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.session-item .rename {
  background: none; border: none; color: rgba(253, 246, 236, 0.55);
  cursor: pointer; font-size: 0.85rem; padding: 0.15rem 0.3rem; border-radius: 6px;
}
.session-item .rename:hover { color: var(--sand); background: rgba(255, 255, 255, 0.12); }
.rename-box { position: relative; }
.rename-box summary { list-style: none; }
.rename-box summary::-webkit-details-marker { display: none; }
.rename-box form {
  position: absolute;
  right: 0; top: calc(100% + 6px);
  width: 230px;
  background: var(--ink);
  border: 1px solid rgba(253, 246, 236, 0.25);
  border-radius: 10px;
  padding: 0.5rem;
  z-index: 20;
}
.rename-box input {
  width: 100%;
  border: 1px solid rgba(253, 246, 236, 0.3);
  background: rgba(255, 255, 255, 0.1);
  color: var(--sand);
  border-radius: 8px;
  padding: 0.3rem 0.5rem;
  font-family: var(--font-body);
  font-size: 0.85rem;
}

.sidebar-foot { border-top: 1px solid rgba(253, 246, 236, 0.15); padding-top: 0.9rem; margin-top: 1rem; font-size: 0.85rem; }
.sidebar-foot .who { color: rgba(253, 246, 236, 0.75); margin-bottom: 0.6rem; overflow: hidden; text-overflow: ellipsis; }
.sidebar-foot .lang-switch { background: rgba(253, 246, 236, 0.1); border-color: rgba(253, 246, 236, 0.2); margin-bottom: 0.7rem; }
.sidebar-foot .lang-switch button { color: rgba(253, 246, 236, 0.7); }
.sidebar-foot .lang-switch button:hover { color: var(--sand); }
.sidebar-foot .lang-switch button.active { background: var(--sea-light); color: var(--ink); }
.sidebar-foot a { color: var(--sea-light); text-decoration: none; display: inline-block; margin-right: 0.9rem; }
.sidebar-foot a:hover { text-decoration: underline; }

.main { padding: 2rem 2.4rem 4rem; max-width: 860px; width: 100%; margin: 0 auto; }

.session-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.6rem;
  flex-wrap: wrap;
}
.session-head h1 { font-size: 1.5rem; }
.countdown {
  display: inline-flex; align-items: center; gap: 0.5rem;
  background: var(--white);
  border: 1.5px solid var(--sea);
  color: var(--sea-deep);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  border-radius: 999px;
  padding: 0.45rem 1rem;
  font-size: 0.95rem;
}
.countdown.low { border-color: var(--coral); color: var(--coral-deep); }
.countdown.over { border-color: var(--hairline); color: var(--ink-soft); background: var(--sand); }

.readonly-badge {
  display: inline-flex; align-items: center; gap: 0.4rem;
  background: var(--sand-2);
  color: var(--ink-soft);
  border-radius: 999px;
  padding: 0.45rem 1rem;
  font-size: 0.85rem;
  font-weight: 600;
}

.head-actions { display: flex; align-items: center; gap: 0.7rem; flex-wrap: wrap; }

.ai-note {
  font-size: 0.82rem;
  color: var(--ink-soft);
  background: var(--sand-2);
  border-radius: 999px;
  display: inline-block;
  padding: 0.35rem 0.9rem;
  margin: -0.6rem 0 1.4rem;
}

.session-item .delete {
  background: none; border: none; color: rgba(253, 246, 236, 0.4);
  cursor: pointer; font-size: 0.8rem; padding: 0.15rem 0.35rem; border-radius: 6px;
}
.session-item .delete:hover { color: var(--coral); background: rgba(255, 107, 94, 0.15); }
.delete-form { display: inline; }

/* Le Chatton Moine, incarné : avatar qui se balance doucement quand il réfléchit */
.moine { width: 74px; height: 74px; margin-bottom: 0.6rem; }
.moine img {
  width: 100%; height: 100%;
  object-fit: cover;
  border-radius: 50%;
  border: 3px solid var(--white);
  box-shadow: 0 10px 26px rgba(23, 63, 63, 0.3);
}
.moine.thinking img { animation: moine-think 3s ease-in-out infinite; }
@keyframes moine-think {
  0%   { transform: translateY(0) rotate(0deg); }
  25%  { transform: translateY(-4px) rotate(-3deg); }
  50%  { transform: translateY(0) rotate(0deg); }
  75%  { transform: translateY(-2px) rotate(3deg); }
  100% { transform: translateY(0) rotate(0deg); }
}
@media (prefers-reduced-motion: reduce) {
  .moine.thinking img { animation: none; }
}

.welcome-card {
  background: var(--white);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  padding: 3rem 2.4rem;
  text-align: center;
  box-shadow: var(--shadow-soft);
  margin-top: 3rem;
}
.welcome-card h2 { font-size: 1.7rem; margin-bottom: 0.8rem; }
.welcome-card p { color: var(--ink-soft); max-width: 34rem; margin: 0 auto 1.8rem; }

#log { display: flex; flex-direction: column; gap: 0.8rem; max-width: 640px; }
.msg {
  padding: 0.85rem 1.1rem;
  border-radius: 1.1rem;
  line-height: 1.55;
  white-space: pre-wrap;
  max-width: 85%;
  font-size: 0.97rem;
}
.msg.you { background: var(--sand-2); align-self: flex-end; border-bottom-right-radius: 0.3rem; }
.msg.coach {
  background: var(--white);
  border: 1px solid var(--hairline);
  align-self: flex-start;
  border-bottom-left-radius: 0.3rem;
  box-shadow: 0 8px 20px rgba(23, 63, 63, 0.06);
}
.msg .memo { margin-top: 0.5rem; display: block; }
.msg .memo audio { width: 240px; height: 34px; }
.err { background: rgba(255, 107, 94, 0.12); color: var(--coral-deep); align-self: center; font-size: 0.85rem; border-radius: 999px; padding: 0.5rem 1rem; }

#dock {
  position: fixed;
  bottom: 1.5rem;
  right: 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 10;
}
.dock-pdf { margin-bottom: 0.8rem; }
#mic {
  width: 168px; height: 168px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  font-size: 4.2rem;
  background: var(--ink);
  transition: all 0.2s;
  box-shadow: 0 14px 40px rgba(23, 63, 63, 0.4);
}
#mic.recording { background: var(--coral); animation: pulse 1.2s infinite; }
#mic:disabled { opacity: 0.4; cursor: not-allowed; }
@keyframes pulse { 50% { transform: scale(1.08); box-shadow: 0 0 0 18px rgba(255, 107, 94, 0.18); } }
#status { margin-top: 0.7rem; color: var(--ink-soft); font-size: 0.88rem; min-height: 1.4em; }
#voice {
  margin-top: 0.5rem;
  background: var(--white);
  color: var(--ink);
  border: 1px solid var(--hairline);
  border-radius: 0.5rem;
  padding: 0.3rem 0.6rem;
  font-size: 0.8rem;
}

.seg-controls { display: flex; flex-direction: column; gap: 0.4rem; align-items: center; }

.lang-switch {
  display: flex;
  background: var(--white);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  padding: 3px;
  margin-top: 0.5rem;
}
.lang-switch button {
  border: none;
  background: transparent;
  border-radius: 999px;
  padding: 0.28rem 0.65rem;
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}
.lang-switch button:hover { color: var(--ink); }
.lang-switch button.active { background: var(--ink); color: var(--sand); }
.lang-switch button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  color: var(--ink-soft) !important;
}
.lang-switch button:disabled:hover {
  background: transparent !important;
  color: var(--ink-soft) !important;
}

/* ---------- admin ---------- */

.admin-main { max-width: 1080px; margin: 0 auto; padding: 2.4rem 2rem 4rem; }
.admin-main h1 { font-size: 1.8rem; margin-bottom: 1.6rem; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 2.2rem; }
.stat-card {
  background: var(--white);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  padding: 1.2rem 1.4rem;
  box-shadow: 0 10px 24px rgba(23, 63, 63, 0.06);
}
.stat-card .k { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-soft); }
.stat-card .v { font-family: var(--font-display); font-size: 1.9rem; font-weight: 700; }
.stat-card .v.coral { color: var(--coral-deep); }
.stat-card .v.sea { color: var(--sea-deep); }

.profile-hint { font-size: 0.85rem; color: var(--ink-soft); margin-bottom: 1.2rem; }
.profile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1.2rem; }
.profile-grid .field-wide { grid-column: 1 / -1; }
@media (max-width: 700px) { .profile-grid { grid-template-columns: 1fr; } }

.admin-section { background: var(--white); border: 1px solid var(--hairline); border-radius: var(--radius-lg); padding: 1.6rem 1.6rem 1.2rem; margin-bottom: 1.6rem; box-shadow: 0 10px 24px rgba(23, 63, 63, 0.05); }
.admin-section h2 { font-size: 1.15rem; margin-bottom: 1rem; }
table.admin { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
table.admin th { text-align: left; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-soft); padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--hairline); }
table.admin td { padding: 0.55rem 0.6rem; border-bottom: 1px solid rgba(23, 63, 63, 0.06); }
table.admin tr:last-child td { border-bottom: none; }
.pill { display: inline-block; border-radius: 999px; padding: 0.15rem 0.7rem; font-size: 0.78rem; font-weight: 600; }
.pill.held { background: rgba(233, 180, 76, 0.25); color: #8a6414; }
.pill.paid { background: rgba(46, 196, 182, 0.2); color: var(--sea-deep); }
.pill.refunded { background: var(--sand-2); color: var(--ink-soft); }

/* ---------- responsive ---------- */

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  #dock { right: 0.8rem; bottom: 0.8rem; }
  #mic { width: 120px; height: 120px; font-size: 3rem; }
  .main { padding: 1.6rem 1.2rem 8rem; }
}
