/* =============================================================
   Storyline Analytics — Shared Stylesheet
   Used by every page. Contains brand colors, fonts, header,
   navigation, and the chat UI styles for the SAGE page.
   ============================================================= */

/* --- GOOGLE FONTS --- */
/* Playfair Display = fancy headings | DM Sans = body text | DM Mono = code/tags */
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@600;700&family=DM+Sans:wght@300;400;500&family=DM+Mono:wght@400;500&display=swap');

/* --- BRAND COLOR VARIABLES ---
   Change these in ONE place and the whole app updates. */
:root {
  --ink:      #0d0f14;   /* darkest background */
  --surface:  #13161e;   /* header, sidebar, input bar */
  --panel:    #1a1e28;   /* cards, message bubbles */
  --border:   #2a2f3f;   /* all dividing lines */
  --gold:     #c9a84c;   /* primary brand accent */
  --gold-dim: #8a6e2f;   /* darker gold for gradients */
  --accent:   #4a7fa5;   /* blue accent */
  --muted:    #5a6278;   /* placeholder / secondary text */
  --text:     #d4d8e8;   /* main readable text */
  --text-dim: #8890a8;   /* softer body text */
  --green:    #3ecf8e;   /* online / success */
  --red:      #e05c5c;   /* error / warning */
}

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

/* Ensure [hidden] always wins over display:flex/grid rules */
[hidden] { display: none !important; }

/* --- BODY --- */
body {
  background: var(--ink);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-weight: 400;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* =============================================================
   HEADER
   The top bar that appears on every page.
   ============================================================= */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  flex-shrink: 0;
  gap: 1rem;
}

/* --- Logo (left side of header) --- */
.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  flex-shrink: 0;
}

.logo-mark {
  width: 44px;
  height: 44px;
  border-radius: 6px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
}

.logo-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.logo-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.logo-name {
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.logo-sub {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 500;
}

/* --- Status chip (right side of header) --- */
.status-chip {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(62,207,142,0.08);
  border: 1px solid rgba(62,207,142,0.2);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 12px;
  color: var(--green);
  font-weight: 500;
  letter-spacing: 0.05em;
  flex-shrink: 0;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.5; transform: scale(0.8); }
}

/* =============================================================
   NAVIGATION BAR
   The row of page links that sits inside the header.
   ============================================================= */
.main-nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

/* Each nav link */
.nav-link {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dim);
  text-decoration: none;
  letter-spacing: 0.03em;
  transition: color 0.15s, background 0.15s;
  white-space: nowrap;
}

.nav-link:hover {
  color: var(--text);
  background: rgba(255,255,255,0.05);
}

/* The currently active page link gets the gold treatment */
.nav-link.active {
  color: var(--gold);
  background: rgba(201,168,76,0.1);
}

.nav-link .nav-icon {
  font-size: 14px;
  line-height: 1;
}

/* =============================================================
   PAGE WRAPPER
   Everything below the header.
   ============================================================= */
.workspace {
  display: flex;
  flex: 1;
  overflow: hidden;
  height: calc(100vh - 64px);
}

/* =============================================================
   SIDEBAR (SAGE chat page only)
   ============================================================= */
.sidebar {
  width: 260px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
}

.sidebar-section {
  padding: 1.25rem 1.25rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

.sidebar-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

.coo-card {
  background: linear-gradient(135deg, rgba(201,168,76,0.1), rgba(74,127,165,0.08));
  border: 1px solid rgba(201,168,76,0.25);
  border-radius: 10px;
  padding: 1rem;
  margin-bottom: 0.5rem;
}

.coo-title {
  font-family: 'Playfair Display', serif;
  font-size: 14px;
  color: var(--gold);
  font-weight: 600;
  margin-bottom: 2px;
}

.coo-name {
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 300;
}

.agent-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.agent-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
  font-size: 13px;
  color: var(--text-dim);
  text-decoration: none;
}

.agent-item:hover  { background: rgba(255,255,255,0.04); color: var(--text); }
.agent-item.active { background: rgba(74,127,165,0.15); color: var(--text); }

.agent-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.agent-dot.web      { background: #4a7fa5; }
.agent-dot.bi       { background: #c9a84c; }
.agent-dot.qa       { background: #3ecf8e; }
.agent-dot.pm       { background: #a46fc9; }
.agent-dot.research { background: #d4956b; }
.agent-dot.idle     { background: var(--border); }

.agent-status-text {
  font-size: 10px;
  color: var(--muted);
  margin-left: auto;
  font-weight: 500;
}

/* Conversation list in sidebar */
.conv-list {
  overflow-y: auto;
  flex: 1;
  padding: 0 0.25rem;
}
.conv-empty {
  font-size: 11px;
  color: var(--muted);
  padding: 0.5rem 0.75rem;
  font-style: italic;
}
.conv-item {
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.12s;
  margin-bottom: 2px;
}
.conv-item:hover   { background: rgba(255,255,255,0.04); }
.conv-item.active  { background: rgba(201,168,76,0.1); border-left: 2px solid var(--gold); }
.conv-item-title {
  font-size: 12px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 400;
}
.conv-item-meta {
  font-size: 10px;
  color: var(--muted);
  margin-top: 2px;
  font-family: 'DM Mono', monospace;
}

.sidebar-bottom {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
}

.clear-btn {
  width: 100%;
  padding: 8px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  transition: all 0.15s;
  letter-spacing: 0.03em;
}

.clear-btn:hover {
  border-color: var(--gold-dim);
  color: var(--gold);
  background: rgba(201,168,76,0.05);
}

/* =============================================================
   CHAT AREA (SAGE chat page only)
   ============================================================= */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-header {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: var(--surface);
  flex-shrink: 0;
}

.create-project-btn {
  padding: 7px 14px;
  background: linear-gradient(135deg, var(--gold), var(--gold-dim));
  border: none;
  border-radius: 8px;
  color: var(--ink);
  font-family: 'DM Sans', sans-serif;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.15s;
  flex-shrink: 0;
}
.create-project-btn:hover { opacity: 0.88; }

.chat-title {
  font-family: 'Playfair Display', serif;
  font-size: 17px;
  color: var(--text);
  font-weight: 600;
}

.chat-subtitle {
  font-size: 12px;
  color: var(--muted);
  margin-top: 1px;
  font-weight: 300;
}

/* --- Message list (scrollable) --- */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  scroll-behavior: smooth;
}

.messages::-webkit-scrollbar       { width: 4px; }
.messages::-webkit-scrollbar-track { background: transparent; }
.messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* --- Welcome card --- */
.welcome-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.75rem;
  margin-bottom: 0.5rem;
}

.welcome-greeting {
  font-family: 'Playfair Display', serif;
  font-size: 22px;
  color: var(--gold);
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.welcome-body {
  font-size: 14px;
  color: var(--text-dim);
  line-height: 1.7;
  font-weight: 300;
  margin-bottom: 1.25rem;
}

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.quick-btn {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 12.5px;
  color: var(--text-dim);
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  transition: all 0.15s;
  font-weight: 400;
}

.quick-btn:hover {
  background: rgba(201,168,76,0.08);
  border-color: rgba(201,168,76,0.3);
  color: var(--gold);
}

/* --- Message bubbles --- */
.message {
  display: flex;
  gap: 0.75rem;
  animation: fadeUp 0.25s ease-out;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.message.user { flex-direction: row-reverse; }

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
  font-weight: 600;
}

.avatar.coo {
  background: linear-gradient(135deg, var(--gold), var(--gold-dim));
  color: var(--ink);
  font-family: 'Playfair Display', serif;
}

.avatar.user {
  background: rgba(74,127,165,0.25);
  border: 1px solid rgba(74,127,165,0.3);
  color: var(--accent);
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.bubble {
  max-width: 72%;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.875rem 1.1rem;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
  font-weight: 300;
}

.message.user .bubble {
  background: rgba(74,127,165,0.12);
  border-color: rgba(74,127,165,0.25);
  color: var(--text);
}

.bubble strong { color: var(--gold); font-weight: 500; }
.bubble em     { color: var(--accent); font-style: normal; font-weight: 500; }
.bubble ul     { padding-left: 1.1rem; margin-top: 0.4rem; }
.bubble li     { margin-bottom: 0.3rem; color: var(--text-dim); }

/* Agent name tags like [Web Dev Agent] */
.bubble .tag {
  display: inline-block;
  background: rgba(201,168,76,0.1);
  border: 1px solid rgba(201,168,76,0.2);
  border-radius: 4px;
  padding: 1px 6px;
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  color: var(--gold);
}

/* --- Typing indicator (animated dots while SAGE is thinking) --- */
.typing {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  animation: fadeUp 0.2s ease-out;
}

.typing-dots {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.875rem 1.1rem;
  display: flex;
  gap: 5px;
  align-items: center;
}

.typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gold-dim);
  animation: typingBounce 1.2s ease-in-out infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40%           { transform: translateY(-5px); opacity: 1; }
}

/* --- Input bar (bottom of chat) --- */
.input-area {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

.input-row {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
}

.input-wrap {
  flex: 1;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex;
  align-items: flex-end;
  padding: 0.6rem 0.75rem;
  transition: border-color 0.15s;
}

.input-wrap:focus-within {
  border-color: rgba(201,168,76,0.4);
}

textarea {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 300;
  resize: none;
  line-height: 1.6;
  max-height: 120px;
  min-height: 24px;
  overflow-y: auto;
}

textarea::placeholder { color: var(--muted); }

.send-btn {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, var(--gold), var(--gold-dim));
  border: none;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.15s, transform 0.1s;
  flex-shrink: 0;
}

.send-btn:hover    { opacity: 0.9; }
.send-btn:active   { transform: scale(0.95); }
.send-btn:disabled { opacity: 0.3; cursor: not-allowed; }

.send-btn svg { width: 18px; height: 18px; fill: var(--ink); }

.input-hint {
  font-size: 11px;
  color: var(--muted);
  margin-top: 0.5rem;
  text-align: center;
  font-weight: 300;
  letter-spacing: 0.02em;
}

/* =============================================================
   PLACEHOLDER PAGES (agents, intake, dashboard)
   Used while those pages are being built out.
   ============================================================= */
.page-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 2rem;
  text-align: center;
}

.page-icon {
  font-size: 48px;
  margin-bottom: 1.5rem;
  opacity: 0.6;
}

.page-title {
  font-family: 'Playfair Display', serif;
  font-size: 28px;
  color: var(--gold);
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.page-description {
  font-size: 15px;
  color: var(--text-dim);
  line-height: 1.7;
  font-weight: 300;
  max-width: 480px;
  margin-bottom: 2rem;
}

.coming-soon-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(201,168,76,0.08);
  border: 1px solid rgba(201,168,76,0.2);
  border-radius: 20px;
  padding: 6px 16px;
  font-size: 12px;
  color: var(--gold);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* =============================================================
   RESPONSIVE — Mobile adjustments
   ============================================================= */
@media (max-width: 768px) {
  /* Collapse logo text on small screens */
  .logo-text  { display: none; }

  /* Stack nav items tighter */
  .nav-link   { padding: 6px 10px; font-size: 12px; }
  .nav-link .nav-icon { display: none; }

  /* Status chip shorter */
  .status-chip { padding: 4px 8px; font-size: 11px; }
}

@media (max-width: 640px) {
  /* Hide sidebar on phone */
  .sidebar    { display: none; }
  .bubble     { max-width: 88%; }
  header      { padding: 0 1rem; }
}
