/* AI Staff Trafic UI — styling on the trafic.com brand
   (retail look: white background, Trafic red primary, yellow swoosh accent,
   Source Sans Pro black headings, Roboto body). The palette and typography are
   lifted from trafic.com/fr_BE; tune the variables below to follow the brand. */

:root {
  /* Trafic brand palette (from trafic.com) */
  --trafic-red: #eb1428;         /* logo / h1 / primary buttons */
  --trafic-red-dark: #c11021;
  --trafic-yellow: #f8a523;      /* logo swoosh */
  --trafic-green: #4eb400;       /* promo green */
  --trafic-ink: #333333;         /* body text */

  --primary: var(--trafic-red);
  --primary-dark: var(--trafic-red-dark);
  --accent: var(--trafic-yellow);
  --ink: var(--trafic-ink);
  --muted: #747474;
  --bg: #ffffff;
  --bg-soft: #f9f9f9;
  --border: #e2e2e2;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(51, 51, 51, 0.06), 0 8px 24px rgba(51, 51, 51, 0.08);
  --maxw: 1080px;
  --font-body: "Roboto", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  /* Source Sans 3 is the current Google Fonts release of Source Sans Pro. */
  --font-heading: "Source Sans 3", "Source Sans Pro", var(--font-body);
}

* { box-sizing: border-box; }

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

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

h1, h2, h3 {
  font-family: var(--font-heading);
}

.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.94);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 3px solid var(--primary);
}

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

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

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

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

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

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

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

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

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

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

/* --- Hero ------------------------------------------------------------------ */

.hero {
  padding: 64px 0 8px;
  background:
    radial-gradient(1200px 300px at 85% -80px, rgba(248, 165, 35, 0.12), transparent 70%),
    var(--bg);
}

.hero-title {
  margin: 0 0 10px;
  font-weight: 900;
  font-size: 2.4rem;
  line-height: 1.2;
  color: var(--primary);
}

.hero-sub {
  margin: 0;
  max-width: 62ch;
  font-size: 1.05rem;
  color: var(--muted);
}

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

.home {
  padding: 44px 0 80px;
}

.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: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
}

.tile {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 20px;
  min-height: 170px;
  padding: 22px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-decoration: none;
  color: var(--ink);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

a.tile:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
  box-shadow: 0 4px 8px rgba(51, 51, 51, 0.08), 0 14px 32px rgba(51, 51, 51, 0.12);
}

.tile-deco {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 150px;
  height: auto;
  pointer-events: none;
}

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

.tile-eyebrow {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.tile-title {
  font-family: var(--font-heading);
  font-weight: 900;
  font-size: 1.35rem;
  color: var(--primary);
}

.tile-sub {
  font-size: 0.92rem;
  color: var(--muted);
  max-width: 34ch;
}

.tile-cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--primary);
}

.tile-chevron { width: 11px; height: 11px; fill: currentColor; }

/* Featured tile — the brand-accent block (AI Staff). */
.tile-feature {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  border-color: var(--primary-dark);
  color: #fff;
}
.tile-feature .tile-eyebrow { color: rgba(255, 255, 255, 0.8); }
.tile-feature .tile-title { color: #fff; }
.tile-feature .tile-sub { color: rgba(255, 255, 255, 0.85); }
.tile-feature .tile-cta { color: var(--accent); }

/* "Coming soon" tiles — visibly not clickable yet. */
.tile-soon { cursor: default; }
.tile-soon .tile-cta { color: var(--muted); }
.tile-soon.tile-feature .tile-cta { color: rgba(255, 255, 255, 0.75); }

/* --- AI Staff: stand-out nav entry ----------------------------------------- */

.nav-cta {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #fff;
  background: var(--primary);
  padding: 7px 15px;
  border-radius: 999px;
  font-weight: 700;
  box-shadow: 0 1px 2px rgba(51, 51, 51, 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;
}

/* --- Panels ------------------------------------------------------------------ */

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

.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: 900;
  color: var(--primary);
}

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

/* --- Buttons ------------------------------------------------------------------ */

.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: 700;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s 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;
}

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

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

/* --- Notices ------------------------------------------------------------------ */

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

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

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

/* --- Chat panel (AI Staff) ----------------------------------------------------- */

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

/* Space tabs: Staff / Segments / Workshop — one conversation thread each */
.chat-spaces {
  display: flex;
  gap: 8px;
  padding: 0 24px 12px;
}

.space-btn {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.95rem;
  padding: 6px 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.space-btn:hover {
  color: var(--ink);
  background: var(--bg-soft);
}

.space-btn.active {
  color: #ffffff;
  background: var(--primary);
  border-color: var(--primary);
}

.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(--ink);
  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;
}

/* Markdown rendered inside assistant bubbles. */
.chat-bubble p,
.chat-bubble ul,
.chat-bubble ol,
.chat-bubble pre,
.chat-bubble blockquote,
.chat-bubble .chat-table {
  margin: 0 0 10px;
}

.chat-bubble > :last-child { margin-bottom: 0; }

.chat-bubble h1,
.chat-bubble h2,
.chat-bubble h3,
.chat-bubble h4 {
  margin: 14px 0 6px;
  line-height: 1.3;
  color: inherit;
}

.chat-bubble > h1:first-child,
.chat-bubble > h2:first-child,
.chat-bubble > h3:first-child,
.chat-bubble > h4:first-child {
  margin-top: 0;
}

.chat-bubble h1 { font-size: 1.15rem; }
.chat-bubble h2 { font-size: 1.08rem; }
.chat-bubble h3 { font-size: 1rem; }
.chat-bubble h4 { font-size: 0.96rem; }

.chat-bubble ul,
.chat-bubble ol {
  padding-left: 22px;
}

.chat-bubble li { margin: 2px 0; }

.chat-bubble li > ul,
.chat-bubble li > ol {
  margin: 2px 0 0;
}

.chat-bubble code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85em;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
}

.chat-bubble pre {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  overflow-x: auto;
}

.chat-bubble pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.85em;
  white-space: pre;
}

.chat-bubble blockquote {
  border-left: 3px solid var(--border);
  padding-left: 12px;
  color: var(--muted);
}

.chat-bubble hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 12px 0;
}

.chat-bubble a {
  color: var(--primary);
}

.chat-table { overflow-x: auto; }

.chat-table table {
  border-collapse: collapse;
  font-size: 0.9em;
}

.chat-table th,
.chat-table td {
  border: 1px solid var(--border);
  padding: 5px 9px;
  text-align: left;
  vertical-align: top;
}

.chat-table th { background: var(--bg-soft); }

/* 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(--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(--ink);
  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(235, 20, 40, 0.15);
}

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

.site-footer {
  border-top: 1px solid var(--border);
  background: var(--bg-soft);
  padding: 18px 0;
  font-size: 0.85rem;
}

.site-footer .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.site-footer .muted { color: var(--muted); }

/* --- Responsive ---------------------------------------------------------------- */

@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; }
  .chat-bubble { max-width: 88%; }
  .chat-log { height: 60vh; padding: 16px; }
  .chat-composer { padding: 12px 16px 16px; }
}

/* --- Auth (login page + navbar account controls) ---------------------------- */

.nav-user {
  color: var(--muted);
  font-size: 0.85rem;
}

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

.nav-logout {
  background: none;
  border: 1px solid var(--muted);
  border-radius: 6px;
  padding: 5px 12px;
  color: var(--muted);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.nav-logout:hover { color: var(--primary); border-color: var(--primary); }

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

.auth-card {
  max-width: 400px;
  margin: 0 auto;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
  padding: 32px;
}

.auth-title {
  margin: 6px 0 6px;
  font-family: var(--font-heading);
  font-weight: 900;
  font-size: 1.6rem;
  color: var(--ink);
}

.auth-sub {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 0.92rem;
}

.auth-error {
  margin: 0 0 16px;
  padding: 10px 14px;
  border-radius: 8px;
  background: rgba(235, 20, 40, 0.08);
  border: 1px solid rgba(235, 20, 40, 0.35);
  color: var(--primary);
  font-size: 0.9rem;
}

.auth-label {
  display: block;
  margin: 14px 0 6px;
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--ink);
}

.auth-input {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  border: 1px solid rgba(0, 0, 0, 0.18);
  border-radius: 8px;
  font: inherit;
  font-size: 0.95rem;
}

.auth-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(235, 20, 40, 0.12);
}

.auth-submit {
  width: 100%;
  margin-top: 22px;
  padding: 11px 0;
  border: none;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font: inherit;
  font-size: 0.98rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.auth-submit:hover { opacity: 0.9; }
