/* ============================================================
   DesignYetu AI Assistant - Design System
   Palette: deep slate (structure) + warm amber (signal/action)
   Type: Space Grotesk (display) / Inter (body) / JetBrains Mono (data)
   Signature: chat-bubble notch motif used sparingly on brand mark,
   status pulses, and empty states - it's the one visual idea this
   product is actually about (a business talking to its customers).
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --ink-900: #0f1420;
  --ink-800: #161d2e;
  --ink-700: #232c42;
  --ink-500: #4b5670;
  --ink-300: #8b93a7;
  --ink-100: #e7e9ef;
  --paper: #faf9f7;
  --paper-raised: #ffffff;
  --line: #e3e1dc;

  --amber: #e08a2c;
  --amber-dark: #b8691a;
  --amber-tint: #fdf0dd;

  --good: #2f7d5e;
  --good-tint: #e5f3ec;
  --bad: #c14545;
  --bad-tint: #fbe9e9;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow: 0 1px 2px rgba(15, 20, 32, 0.06), 0 8px 24px -12px rgba(15, 20, 32, 0.12);

  --font-display: 'Space Grotesk', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink-900);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .display {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink-900);
  margin: 0;
}

.mono { font-family: var(--font-mono); }

a { color: var(--amber-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

button, input, textarea, select { font-family: inherit; font-size: inherit; }

:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}

/* ---------- Brand mark: chat bubble with a signal notch ---------- */
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--ink-900);
}
.brand-mark {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  object-fit: contain;
}

/* ---------- Auth pages (login/register) ---------- */
.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
}
@media (max-width: 860px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-aside { display: none; }
}
.auth-aside {
  background: var(--ink-900);
  color: var(--paper);
  padding: 48px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}
.auth-aside::before {
  content: "";
  position: absolute;
  right: -80px;
  bottom: -80px;
  width: 340px;
  height: 340px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(224,138,44,0.25), transparent 70%);
}
.auth-aside .brand { color: var(--paper); font-size: 1.2rem; }
.auth-pitch h1 {
  color: var(--paper);
  font-size: 2rem;
  line-height: 1.25;
  max-width: 22ch;
}
.auth-pitch p {
  color: var(--ink-100);
  opacity: 0.8;
  max-width: 40ch;
  margin-top: 12px;
}
.auth-quote {
  border-left: 2px solid var(--amber);
  padding-left: 16px;
  font-size: 0.9rem;
  color: var(--ink-100);
  opacity: 0.75;
}
.auth-main {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
}
.auth-card { width: 100%; max-width: 380px; }
.auth-card h2 { font-size: 1.5rem; margin-bottom: 6px; }
.auth-card .sub { color: var(--ink-500); margin-bottom: 28px; font-size: 0.92rem; }

/* ---------- Forms ---------- */
.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink-700);
  margin-bottom: 6px;
}
.field input,
.field textarea,
.field select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper-raised);
  color: var(--ink-900);
  font-size: 16px;
}
@media (max-width: 480px) {
  .field input,
  .field textarea,
  .field select {
    padding: 12px 10px;
    font-size: 16px;
  }
}
.field textarea { resize: vertical; min-height: 90px; }
.field input:focus, .field textarea:focus, .field select:focus {
  border-color: var(--amber);
}
.field .hint { font-size: 0.78rem; color: var(--ink-300); margin-top: 4px; }

.checkbox-field { margin-top: 4px; }
.checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.85rem;
  color: var(--ink-700);
  line-height: 1.5;
  cursor: pointer;
}
.checkbox-label input {
  width: 16px;
  height: 16px;
  margin-top: 2px;
  accent-color: var(--amber);
  flex-shrink: 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease;
  min-height: 44px;
}
@media (max-width: 480px) {
  .btn {
    padding: 12px 16px;
    font-size: 0.85rem;
    min-height: 48px;
  }
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--amber); color: var(--ink-900); }
.btn-primary:hover { background: var(--amber-dark); color: #fff; }
.btn-block { width: 100%; }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink-700); }
.btn-ghost:hover { border-color: var(--ink-500); }
.btn-danger { background: var(--bad-tint); color: var(--bad); }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
@media (max-width: 480px) {
  .btn-sm {
    padding: 8px 14px;
    font-size: 0.75rem;
  }
}

.alert {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  margin-bottom: 16px;
}
.alert-error { background: var(--bad-tint); color: var(--bad); }
.alert-success { background: var(--good-tint); color: var(--good); }
.alert-warning { background: var(--amber-tint); color: var(--amber-dark); }
.alert-info { background: var(--ink-100); color: var(--ink-700); }

.badge-amber { background: var(--amber-tint); color: var(--amber-dark); }

.segmented {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-top: 8px;
}
.seg-btn {
  padding: 8px 18px;
  border: none;
  background: #fff;
  color: var(--ink-700);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  border-right: 1px solid var(--line);
}
.seg-btn:last-child { border-right: none; }
.seg-btn.active { background: var(--amber); color: var(--ink-900); }
.seg-btn:hover:not(.active) { background: var(--ink-100); }

/* ---------- App shell (dashboard) ---------- */
.app-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}
.app-shell .sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
  .app-shell .sidebar {
    position: fixed;
    inset: 0 auto auto 0;
    width: min(280px, 80vw);
    max-width: 320px;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 30;
    height: 100vh;
    overflow-y: auto;
    box-shadow: 16px 0 48px rgba(15, 20, 32, 0.18);
  }
  .app-shell.nav-open .sidebar {
    transform: translateX(0);
  }
  .app-shell .main-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
  }
  .mobile-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 16px 18px;
    background: var(--paper);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 20;
  }
  .mobile-topbar .brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 1rem;
    color: var(--ink-900);
  }
  .mobile-topbar .brand-mark { width: 26px; height: 26px; }
  .hamburger {
    width: 42px;
    height: 42px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--paper-raised);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
  }
  .hamburger:hover { border-color: var(--ink-300); }
  .hamburger span {
    display: block;
    width: 18px;
    height: 2px;
    border-radius: 1px;
    background: var(--ink-900);
    box-shadow: 0 6px 0 var(--ink-900), 0 -6px 0 var(--ink-900);
  }
  .sidebar-footer { padding-bottom: 22px; }
  .sidebar { padding-top: 16px; }
  .sidebar .brand { margin-bottom: 18px; }
  .mobile-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 20, 32, 0.44);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 25;
  }
  .app-shell.nav-open .mobile-backdrop {
    opacity: 1;
    pointer-events: auto;
  }
}
.sidebar {
  background: var(--ink-900);
  color: var(--ink-100);
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
}
.sidebar .brand { color: var(--paper); margin-bottom: 28px; padding: 0 6px; }
.nav-group { margin-bottom: 4px; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--ink-100);
  opacity: 0.75;
  font-size: 0.88rem;
  font-weight: 500;
  margin-bottom: 2px;
}
.nav-link:hover { background: var(--ink-800); opacity: 1; text-decoration: none; }
.nav-link.active { background: var(--ink-700); opacity: 1; color: #fff; }
.nav-link .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--amber); opacity: 0; }
.nav-link.active .dot { opacity: 1; }

/* Main content area - responsive padding */
.main {
  padding: 28px 32px;
  overflow-y: auto;
}
@media (max-width: 760px) {
  .main {
    padding: 20px 16px;

  }
}
@media (max-width: 480px) {
  .main {
    padding: 16px 12px;
  }
}
.sidebar-footer {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 0.8rem;
}
.sidebar-footer .who { color: var(--paper); font-weight: 600; }
.sidebar-footer .role { color: var(--ink-300); text-transform: capitalize; }
.sidebar-footer button { margin-top: 10px; }

.main {
  padding: 28px 36px 60px;
  max-width: 1080px;
}
@media (max-width: 760px) {
  .main {
    padding: 20px 16px 40px;
    overflow-y: auto;
  }
}
@media (max-width: 480px) {
  .main {
    padding: 16px 12px 36px;
  }
}
.page-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 26px;
  flex-wrap: wrap;
}
@media (max-width: 480px) {
  .page-header {
    margin-bottom: 20px;
  }
}
.page-header h1 { font-size: 1.6rem; }
@media (max-width: 480px) {
  .page-header h1 { font-size: 1.3rem; }
}
.page-header .sub { color: var(--ink-500); font-size: 0.92rem; margin-top: 4px; }
@media (max-width: 480px) {
  .page-header .sub { font-size: 0.8rem; }
}

/* ---------- Cards / stats ---------- */
.card {
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow);
}
@media (max-width: 760px) {
  .card {
    padding: 18px;
    border-radius: var(--radius);
  }
}
@media (max-width: 480px) {
  .card {
    padding: 14px;
    border-radius: var(--radius-sm);
  }
}
.card + .card { margin-top: 18px; }
.card h2 { font-size: 1.05rem; margin-bottom: 4px; }
@media (max-width: 480px) {
  .card h2 { font-size: 0.95rem; }
}
.card .sub { color: var(--ink-500); font-size: 0.85rem; margin-bottom: 18px; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 26px;
}
@media (max-width: 1024px) { .stat-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 760px) { .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; } }
@media (max-width: 480px) { .stat-grid { grid-template-columns: 1fr; gap: 10px; } }
.stat-card {
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}
@media (max-width: 480px) {
  .stat-card {
    padding: 14px;
    border-radius: var(--radius-sm);
  }
}
.stat-card .label {
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-300);
  font-weight: 600;
}
.stat-card .value {
  font-family: var(--font-display);
  font-size: 1.7rem;
  margin-top: 6px;
}
.stat-card .value.mono { font-family: var(--font-mono); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 600;
}
.badge-good { background: var(--good-tint); color: var(--good); }
.badge-bad { background: var(--bad-tint); color: var(--bad); }
.badge-neutral { background: var(--ink-100); color: var(--ink-700); }
.badge .pulse {
  width: 6px; height: 6px; border-radius: 50%; background: currentColor;
}
.badge-good .pulse { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }

/* ---------- Tables / lists ---------- */
table { width: 100%; border-collapse: collapse; }
th, td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  font-size: 0.88rem;
}
@media (max-width: 480px) {
  th, td {
    padding: 8px 6px;
    font-size: 0.78rem;
  }
}
th { color: var(--ink-500); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; }
tr:last-child td { border-bottom: none; }
td.mono { font-family: var(--font-mono); font-size: 0.82rem; }
@media (max-width: 480px) {
  td.mono { font-size: 0.74rem; }
}

.list-item {
  width: 100%;
  padding: 14px 4px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  color: inherit;
  text-align: left;
}
.list-item:hover { background: var(--amber-tint); }
.list-item:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: -2px;
  border-radius: 8px;
}
.list-item:last-child { border-bottom: none; }

/* ---------- Empty state (signature motif) ---------- */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--ink-500);
}
.empty-state svg { margin-bottom: 14px; opacity: 0.7; }
.empty-state h3 { color: var(--ink-700); font-size: 1rem; margin-bottom: 4px; }

/* ---------- Knowledge item cards ---------- */
.kb-item {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
}
.kb-item .kb-top { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.kb-item .kb-title { font-weight: 600; }
.kb-item .kb-type {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--amber-dark);
  background: var(--amber-tint);
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 700;
}
.kb-item p { color: var(--ink-500); font-size: 0.88rem; margin: 8px 0 0; }
.kb-actions { margin-top: 10px; display: flex; gap: 8px; }

/* ---------- Chat preview bubbles ---------- */
.bubble-row { display: flex; margin-bottom: 10px; }
.bubble-row.user { justify-content: flex-end; }
.bubble {
  max-width: 75%;
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 0.88rem;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
}
.bubble-row.assistant .bubble { background: var(--ink-100); color: var(--ink-900); border-bottom-left-radius: 4px; }
.bubble-row.user .bubble { background: var(--amber); color: var(--ink-900); border-bottom-right-radius: 4px; }

/* ---------- Notification toast system ---------- */
.notification-toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 10000;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 380px;
}

.notification-sound-toggle {
  position: fixed;
  right: 24px;
  bottom: 86px;
  z-index: 10001;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper-raised);
  color: var(--ink-500);
  box-shadow: var(--shadow);
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 600;
}

.notification-sound-toggle:hover,
.notification-sound-toggle[aria-pressed="true"] {
  background: var(--amber-tint);
  color: var(--ink-900);
}

@media (max-width: 600px) {
  .notification-sound-toggle {
    right: 12px;
    bottom: 74px;
  }

  .notification-toast-container {
    left: 12px;
    right: 12px;
    max-width: none;
    bottom: 12px;
  }
}

.notification-toast {
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow), 0 4px 16px rgba(15, 20, 32, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  pointer-events: all;
  opacity: 0;
  transform: translateX(400px) translateY(20px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.notification-toast.show {
  opacity: 1;
  transform: translateX(0) translateY(0);
}

@media (max-width: 600px) {
  .notification-toast {
    transform: translateX(0) translateY(400px);
  }
  .notification-toast.show {
    transform: translateX(0) translateY(0);
  }
}

.notification-toast-content {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.notification-toast-message {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--ink-900);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.notification-toast-action {
  padding: 6px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--amber-dark);
  background: var(--amber-tint);
  border: none;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.2s ease, color 0.2s ease;
}

.notification-toast-action:hover {
  background: var(--amber);
  color: var(--ink-900);
}

.notification-toast-action:active {
  opacity: 0.8;
}

.notification-toast-dismiss {
  width: 24px;
  height: 24px;
  padding: 0;
  background: none;
  border: none;
  color: var(--ink-300);
  cursor: pointer;
  font-size: 1.2rem;
  line-height: 1;
  flex-shrink: 0;
  transition: color 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.notification-toast-dismiss:hover {
  color: var(--ink-500);
}
.bubble-row.staff .bubble { background: var(--ink-900); color: #fff; border-bottom-left-radius: 4px; }

.code-box {
  background: var(--ink-900);
  color: #d7e0f0;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  overflow-x: auto;
  white-space: pre;
}

.loading { color: var(--ink-300); font-size: 0.88rem; padding: 20px 0; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 760px) { 
  .grid-2 { grid-template-columns: 1fr; }
  .grid-2 .card:nth-child(2) { order: -1; }
}

.plan-card {
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease, box-shadow 0.12s ease;
}
.plan-card:hover {
  transform: translateY(-1px);
  border-color: var(--amber);
  background: var(--amber-tint);
}
.plan-card:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}
.plan-card.is-selected {
  background: var(--amber-tint);
  border-color: var(--amber);
  box-shadow: 0 0 0 1px rgba(224, 138, 44, 0.2);
}
