/* ============================================================
   Mac Coy Chat — app.css
   Bradroit Solutions Design System
   Couleurs : teal #004755 | orange #f1a13b | crème #FAFAE8
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=DM+Mono:wght@400;500&display=swap');

:root {
  --teal:        #004755;
  --teal-dark:   #002f3a;
  --teal-light:  #005f72;
  --teal-muted:  #e6f0f2;
  --orange:      #f1a13b;
  --orange-dark: #d8882a;
  --orange-light:#fdf0db;
  --cream:       #FAFAE8;
  --cream-dark:  #f1f1da;
  --white:       #ffffff;
  --grey-50:     #f7f8fa;
  --grey-100:    #eef0f3;
  --grey-200:    #dde1e7;
  --grey-300:    #c2c9d3;
  --grey-500:    #7e8fa3;
  --grey-700:    #3f4f5e;
  --grey-900:    #1a2530;
  --danger:      #c0392b;
  --danger-bg:   #fdf3f2;
  --success:     #1a7a4a;

  --font-ui:     'DM Sans', ui-sans-serif, system-ui, sans-serif;
  --font-mono:   'DM Mono', ui-monospace, monospace;

  --radius-sm:   6px;
  --radius-md:   10px;
  --radius-lg:   16px;
  --radius-xl:   24px;

  --shadow-xs:   0 1px 3px rgba(0,0,0,.07);
  --shadow-sm:   0 2px 8px rgba(0,0,0,.09);
  --shadow-md:   0 4px 20px rgba(0,0,0,.11);
  --shadow-lg:   0 8px 40px rgba(0,0,0,.13);

  --topbar-h:    62px;
}

/* ─── Reset ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.6;
  color: var(--grey-900);
  background: var(--cream);
  min-height: 100vh;
}

/* ─── Topbar ───────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 24px;
  height: var(--topbar-h);
  background: var(--teal-dark);
  border-bottom: 3px solid var(--orange);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-md);
}

.topbar h1 {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 17px;
  font-weight: 600;
  color: var(--white);
  letter-spacing: .01em;
  white-space: nowrap;
  flex-shrink: 0;
}

.topbar h1 .logo-img {
  height: 36px;
  width: auto;
  display: block;
}

.topbar h1 .app-name {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.topbar h1 .app-name span:first-child {
  font-size: 16px;
  font-weight: 700;
  color: var(--white);
  letter-spacing: .02em;
}

.topbar h1 .app-name span:last-child {
  font-size: 11px;
  font-weight: 400;
  color: var(--orange);
  letter-spacing: .06em;
  text-transform: uppercase;
}

/* ─── Nav tabs ─────────────────────────────────────────────── */
nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

nav button {
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 500;
  color: rgba(255,255,255,.65);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 7px 14px;
  cursor: pointer;
  transition: color .18s, background .18s, border-color .18s;
  white-space: nowrap;
}

nav button:hover {
  color: var(--white);
  background: rgba(255,255,255,.08);
}

nav button.active {
  color: var(--teal-dark);
  background: var(--orange);
  border-color: var(--orange);
  font-weight: 600;
}

nav button#logout {
  margin-left: 12px;
  color: rgba(255,255,255,.55);
  border-color: rgba(255,255,255,.2);
  padding: 6px 13px;
}

nav button#logout:hover {
  color: var(--white);
  background: rgba(193,57,43,.35);
  border-color: var(--danger);
}

/* ─── Main layout ──────────────────────────────────────────── */
main {
  padding: 24px;
  max-width: 1400px;
  margin: 0 auto;
}

/* ─── Tabs visibility ──────────────────────────────────────── */
.tab { display: none; }
.tab.active { display: block; }

/* ─── Chat: message list ────────────────────────────────────── */
.messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 52vh;
  max-height: 62vh;
  overflow-y: auto;
  padding: 16px;
  background: var(--white);
  border: 1px solid var(--grey-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs) inset;
  scroll-behavior: smooth;
}

.messages:empty::after {
  content: 'Aucun message pour l\'instant…';
  color: var(--grey-300);
  font-size: 13px;
  text-align: center;
  margin: auto;
  display: block;
  padding: 40px 0;
}

/* ─── Bulles de message ─────────────────────────────────────── */
.msg {
  max-width: 78%;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  white-space: pre-wrap;
  line-height: 1.55;
  font-size: 14px;
  box-shadow: var(--shadow-xs);
}

.msg.user {
  background: var(--teal);
  color: var(--white);
  align-self: flex-end;
  border-bottom-right-radius: 3px;
}

.msg.assistant {
  background: var(--grey-50);
  color: var(--grey-900);
  border: 1px solid var(--grey-200);
  align-self: flex-start;
  border-bottom-left-radius: 3px;
}

.msg.system {
  background: var(--orange-light);
  color: var(--grey-700);
  border: 1px solid #f5d49a;
  align-self: center;
  font-size: 12.5px;
  max-width: 92%;
  font-style: italic;
}

/* ─── Chat form ─────────────────────────────────────────────── */
.chat-form {
  margin-top: 14px;
  display: grid;
  grid-template-columns: 220px 1fr auto;
  gap: 10px;
  align-items: end;
}

/* ─── Form controls ─────────────────────────────────────────── */
input, textarea, select {
  font-family: var(--font-ui);
  font-size: 14px;
  color: var(--grey-900);
  background: var(--white);
  border: 1.5px solid var(--grey-200);
  border-radius: var(--radius-md);
  padding: 10px 13px;
  transition: border-color .18s, box-shadow .18s;
  width: 100%;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(0,71,85,.12);
}

input::placeholder, textarea::placeholder {
  color: var(--grey-300);
}

textarea {
  resize: vertical;
  line-height: 1.55;
}

select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%237e8fa3' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 34px;
}

/* ─── Boutons principaux ────────────────────────────────────── */
button {
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border-radius: var(--radius-md);
  padding: 10px 20px;
  border: 1.5px solid transparent;
  transition: background .18s, border-color .18s, box-shadow .18s, transform .1s;
  white-space: nowrap;
}

button:active { transform: translateY(1px); }

/* Bouton primaire (submit / Envoyer) */
.chat-form button,
.login-card button[type="submit"] {
  background: var(--orange);
  color: var(--teal-dark);
  border-color: var(--orange);
  box-shadow: var(--shadow-xs);
}

.chat-form button:hover,
.login-card button[type="submit"]:hover {
  background: var(--orange-dark);
  border-color: var(--orange-dark);
  box-shadow: var(--shadow-sm);
}

/* ─── pre / code blocks ─────────────────────────────────────── */
pre {
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--white);
  border: 1px solid var(--grey-200);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  min-height: 60vh;
  overflow: auto;
  color: var(--grey-700);
  box-shadow: var(--shadow-xs);
}

/* ─── Split layout (Sessions / Logs / Skills) ───────────────── */
.split {
  display: grid;
  grid-template-columns: minmax(240px, 30%) 1fr;
  gap: 16px;
  align-items: start;
}

ul {
  list-style: none;
  background: var(--white);
  border: 1px solid var(--grey-200);
  border-radius: var(--radius-lg);
  overflow: auto;
  max-height: 75vh;
  box-shadow: var(--shadow-xs);
}

li {
  padding: 11px 16px;
  border-bottom: 1px solid var(--grey-100);
  cursor: pointer;
  color: var(--grey-700);
  font-size: 13px;
  transition: background .14s, color .14s;
  word-break: break-all;
}

li:last-child { border-bottom: none; }

li:hover {
  background: var(--teal-muted);
  color: var(--teal-dark);
}

li.active {
  background: var(--teal-muted);
  color: var(--teal);
  font-weight: 600;
  border-left: 3px solid var(--teal);
}

/* ─── Section labels ────────────────────────────────────────── */
.section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--grey-500);
  margin-bottom: 10px;
}

/* ─── Status tab ─────────────────────────────────────────────── */
#tab-status pre,
#tab-config pre {
  min-height: 65vh;
}

/* ─── Login page ─────────────────────────────────────────────── */
body.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: var(--teal-dark);
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(0,95,114,.4) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(241,161,59,.12) 0%, transparent 50%);
}

.login-card {
  width: min(420px, 92vw);
  background: var(--white);
  border-radius: var(--radius-xl);
  padding: 40px 36px 36px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.login-card .login-logo {
  display: block;
  width: 180px;
  margin: 0 auto;
}

.login-card .login-title {
  text-align: center;
}

.login-card .login-title h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--teal-dark);
  margin-bottom: 4px;
}

.login-card .login-title p {
  font-size: 13px;
  color: var(--grey-500);
}

.login-card form {
  display: grid;
  gap: 16px;
}

.login-card label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--grey-700);
}

.login-card input {
  font-size: 15px;
  padding: 12px 14px;
}

.login-card button[type="submit"] {
  font-size: 15px;
  padding: 13px;
  width: 100%;
  border-radius: var(--radius-md);
  margin-top: 4px;
  letter-spacing: .02em;
}

.login-footer {
  text-align: center;
  font-size: 11.5px;
  color: var(--grey-300);
  margin-top: 4px;
}

/* ─── Error messages ─────────────────────────────────────────── */
.error {
  font-size: 13px;
  color: var(--danger);
  background: var(--danger-bg);
  border: 1px solid #f5c6c2;
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  min-height: 0;
  display: none;
}

.error:not(:empty) {
  display: block;
}

/* ─── Scrollbars ─────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--grey-200); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--grey-300); }

/* ─── Responsive ─────────────────────────────────────────────── */
@media (max-width: 860px) {
  .topbar {
    height: auto;
    flex-direction: column;
    align-items: flex-start;
    padding: 14px 16px;
    gap: 10px;
  }

  .chat-form {
    grid-template-columns: 1fr;
  }

  .split {
    grid-template-columns: 1fr;
  }

  main { padding: 14px; }
}
