/* ─── App Shell ──────────────────────────────────────────────────── */
.app-shell { display: flex; min-height: 100vh; }

/* ─── Sidebar ───────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width); min-height: 100vh;
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; z-index: 100;
}
.sidebar-header {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 1.25rem 1rem; border-bottom: 1px solid var(--border-light);
}
.sidebar-logo {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--accent); color: #fff; font-weight: 800; font-size: 0.85rem;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.sidebar-logo-img {
  width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0;
}
.sidebar-title { font-weight: 600; font-size: 0.9rem; line-height: 1.2; }
.sidebar-subtitle { margin-top: 1px; }
.sidebar-nav { flex: 1; padding: 0.5rem; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.55rem 0.75rem; border-radius: var(--radius-sm);
  font-size: 0.88rem; color: var(--ink-secondary); text-decoration: none;
  transition: background 0.12s, color 0.12s;
}
.nav-item:hover { background: var(--surface-hover); color: var(--ink); text-decoration: none; }
.nav-item.active { background: var(--accent-light); color: var(--accent-dark); font-weight: 600; }
.nav-item--subtle { color: var(--muted); font-size: 0.82rem; }
.nav-icon { width: 20px; text-align: center; font-size: 1rem; }
.sidebar-footer { padding: 0.5rem; border-top: 1px solid var(--border-light); }

/* ─── Main ──────────────────────────────────────────────────────── */
.main { flex: 1; min-width: 0; padding: 1.5rem 2rem 6rem; }
.page { display: none; }
.page.active { display: block; }
.page-title { margin-bottom: 1.25rem; }
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.25rem; }
.section-title { font-size: 0.95rem; color: var(--ink-secondary); margin: 1.75rem 0 0.75rem; font-weight: 600; }

/* ─── Attention Banner ──────────────────────────────────────────── */
.attention-banner {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.7rem 1rem; margin-bottom: 1.25rem;
  background: var(--warning-light); border: 1px solid #fcd34d;
  border-radius: var(--radius); font-size: 0.88rem;
}
.attention-banner__icon { font-size: 1.1rem; }
.attention-banner__text { flex: 1; color: #92400e; }
.attention-banner__link { color: #92400e; font-weight: 600; white-space: nowrap; text-decoration: none; }
.attention-banner__link:hover { text-decoration: underline; }

/* ─── Briefing Card ─────────────────────────────────────────────── */
.briefing-card { padding: 1.25rem 1.5rem; line-height: 1.7; }
.briefing-card p { margin: 0; }
.briefing-loading { text-align: center; padding: 1.5rem; }
.briefing-line { display: flex; align-items: baseline; gap: 0.5rem; margin-bottom: 0.2rem; }
.briefing-num { font-size: 1.3rem; font-weight: 700; color: var(--accent-dark); min-width: 28px; text-align: right; }
.briefing-text { font-size: 0.92rem; color: var(--ink-secondary); }
.briefing-zero { color: var(--muted); font-size: 0.88rem; padding: 0.5rem 0; }

/* ─── Team Strip (home page — agent aliveness) ──────────────────── */
.team-strip { display: flex; gap: 0.75rem; overflow-x: auto; padding-bottom: 0.5rem; }
.team-chip {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.6rem 1rem; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border);
  white-space: nowrap; min-width: 0; cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.team-chip:hover { border-color: var(--accent); box-shadow: var(--shadow-sm); }
.team-chip__dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.team-chip__dot--active { background: var(--success); box-shadow: 0 0 4px rgba(34,197,94,0.5); }
.team-chip__dot--idle { background: var(--border); }
.team-chip__dot--paused { background: var(--warning); }
.team-chip__name { font-weight: 600; font-size: 0.85rem; }
.team-chip__status { font-size: 0.72rem; color: var(--muted); }

/* ─── Team Grid (Your Team page) ────────────────────────────────── */
.team-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 0.75rem; }
.team-member-card { padding: 1.25rem; }
.team-member-card__header { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.75rem; }
.team-member-card__avatar {
  width: 40px; height: 40px; border-radius: 12px;
  background: var(--accent-light); color: var(--accent-dark);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; flex-shrink: 0;
}
.team-member-card__name { font-weight: 600; font-size: 1rem; }
.team-member-card__role { font-size: 0.78rem; color: var(--muted); }
.team-member-card__alive {
  display: flex; align-items: center; gap: 0.4rem;
  font-size: 0.78rem; color: var(--muted); margin-bottom: 0.6rem;
}
.team-member-card__actions { display: flex; flex-direction: column; gap: 0.35rem; }
.team-member-card__action {
  display: flex; align-items: baseline; gap: 0.4rem;
  font-size: 0.82rem; color: var(--ink-secondary); line-height: 1.4;
}
.team-member-card__action-time { font-size: 0.7rem; color: var(--muted); white-space: nowrap; }

/* ─── Handled List (home page + what happened) ──────────────────── */
.handled-list { display: flex; flex-direction: column; gap: 0.4rem; }
.handled-item {
  display: flex; align-items: flex-start; gap: 0.65rem;
  padding: 0.6rem 0.75rem;
  background: var(--surface); border: 1px solid var(--border-light);
  border-radius: var(--radius-sm); font-size: 0.85rem;
}
.handled-item__who {
  font-weight: 600; color: var(--accent-dark);
  white-space: nowrap; min-width: 0;
}
.handled-item__what { flex: 1; color: var(--ink-secondary); min-width: 0; }
.handled-item__when { font-size: 0.72rem; color: var(--muted); white-space: nowrap; flex-shrink: 0; }

/* ─── Message List ──────────────────────────────────────────────── */
.message-list { display: flex; flex-direction: column; gap: 0.5rem; }
.message-item {
  padding: 0.85rem 1rem; background: var(--surface);
  border: 1px solid var(--border-light); border-radius: var(--radius);
}
.message-item__header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.4rem; }
.message-item__from { font-weight: 600; font-size: 0.9rem; }
.message-item__channel { font-size: 0.7rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.message-item__preview { font-size: 0.85rem; color: var(--ink-secondary); margin-bottom: 0.4rem; }
.message-item__footer { display: flex; align-items: center; gap: 0.5rem; font-size: 0.75rem; color: var(--muted); }
.message-item__handler { color: var(--accent-dark); font-weight: 500; }
.message-item--escalated { border-left: 3px solid var(--warning); }

/* ─── Filter Bar ────────────────────────────────────────────────── */
.filter-bar { display: flex; gap: 0.5rem; margin-bottom: 1rem; flex-wrap: wrap; }
.filter-select { width: auto; min-width: 130px; padding: 0.4rem 0.6rem; font-size: 0.82rem; }

/* ─── Cost Bars ─────────────────────────────────────────────────── */
.cost-row { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.75rem; }
.cost-row__label { width: 140px; font-size: 0.85rem; font-weight: 500; flex-shrink: 0; }
.cost-row__bar-wrap { flex: 1; height: 24px; background: var(--border-light); border-radius: 12px; overflow: hidden; }
.cost-row__bar { height: 100%; background: var(--accent); border-radius: 12px; transition: width 0.4s ease; }
.cost-row__value { width: 70px; text-align: right; font-size: 0.82rem; color: var(--ink-secondary); flex-shrink: 0; }

/* ─── Taskbar ───────────────────────────────────────────────────── */
.taskbar {
  position: fixed; bottom: 0; left: var(--sidebar-width); right: 0;
  padding: 0; background: var(--surface); border-top: 1px solid var(--border);
  box-shadow: 0 -2px 8px rgba(0,0,0,0.05); z-index: 50;
}
.taskbar-row { display: flex; gap: 0.5rem; padding: 0.75rem 1.5rem; }
.taskbar-input {
  flex: 1; padding: 0.55rem 0.85rem;
  font-family: var(--font); font-size: 0.9rem;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg); transition: border-color 0.15s;
}
.taskbar-input:focus { outline: none; border-color: var(--accent); }
.taskbar-btn { border-radius: var(--radius); }

/* Taskbar feedback strip */
.taskbar-feedback {
  padding: 0.45rem 1.5rem;
  background: var(--accent-light); border-bottom: 1px solid #c6e8e4;
  font-size: 0.82rem; color: var(--accent-dark);
  animation: feedbackSlide 0.25s ease;
}
@keyframes feedbackSlide { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

/* ─── Hamburger ─────────────────────────────────────────────────── */
.hamburger {
  display: none; position: fixed; top: 0.75rem; left: 0.75rem;
  z-index: 200; width: 40px; height: 40px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-size: 1.2rem; cursor: pointer;
}

/* ─── Chat Page ────────────────────────────────────────────────── */
.chat-page {
  display: flex; flex-direction: column;
  height: calc(100vh - 1.5rem); /* account for main padding-top */
  margin: -1.5rem -2rem -6rem; /* fill the .main padding */
  padding: 0;
}
.chat-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}
.chat-header__info { display: flex; align-items: center; gap: 0.5rem; }
.chat-header__dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--border); flex-shrink: 0;
}
.chat-header__dot.connected { background: var(--success); box-shadow: 0 0 4px rgba(34,197,94,0.5); }
.chat-header__name { font-weight: 600; font-size: 0.95rem; }
.chat-header__status { font-size: 0.78rem; color: var(--muted); }

/* Chat messages container */
.chat-messages {
  flex: 1; overflow-y: auto; padding: 1.25rem 1.25rem 0.5rem;
  display: flex; flex-direction: column; gap: 0.5rem;
}

/* Welcome state */
.chat-welcome {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  flex: 1; text-align: center; padding: 2rem;
}

/* Chat bubbles */
.chat-bubble {
  max-width: 72%; padding: 0.75rem 1rem;
  border-radius: 20px; line-height: 1.55;
  font-size: 0.9375rem; word-wrap: break-word; overflow-wrap: break-word;
  animation: bubbleIn 250ms cubic-bezier(0.23, 1, 0.32, 1);
}
@keyframes bubbleIn {
  from { opacity: 0; transform: translateY(6px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.chat-bubble--user {
  align-self: flex-end;
  background: var(--accent); color: #fff;
  border-bottom-right-radius: 6px;
  box-shadow: 0 1px 3px rgba(90,180,172,0.2);
}
.chat-bubble--assistant {
  align-self: flex-start;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--border);
  border-bottom-left-radius: 6px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.chat-bubble--error {
  align-self: flex-start;
  background: var(--error-light); color: #b91c1c;
  border: 1px solid #fecaca;
  border-bottom-left-radius: 6px;
}
.chat-bubble--streaming {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(90,180,172,0.1), 0 1px 3px rgba(0,0,0,0.04);
}
.chat-bubble__content { overflow-wrap: break-word; }
.chat-bubble__time {
  font-size: 0.65rem; color: var(--muted);
  margin-top: 0.25rem; opacity: 0.6;
}
.chat-bubble--user .chat-bubble__time { color: rgba(255,255,255,0.6); text-align: right; }

/* Markdown in assistant bubbles */
.chat-bubble--assistant .chat-bubble__content p { margin: 0 0 0.5em; }
.chat-bubble--assistant .chat-bubble__content p:last-child { margin-bottom: 0; }
.chat-bubble--assistant .chat-bubble__content code {
  background: var(--bg); padding: 0.125em 0.375em;
  border-radius: 4px; font-size: 0.85em;
}
.chat-bubble--assistant .chat-bubble__content pre {
  background: #1e1e2e; color: #cdd6f4;
  padding: 0.75rem; border-radius: var(--radius-sm);
  overflow-x: auto; margin: 0.5em 0;
  font-size: 0.8em; line-height: 1.5;
}
.chat-bubble--assistant .chat-bubble__content pre code {
  background: none; padding: 0; border-radius: 0; color: inherit;
}
.chat-bubble--assistant .chat-bubble__content ul,
.chat-bubble--assistant .chat-bubble__content ol {
  padding-left: 1.25em; margin: 0.5em 0;
}
.chat-bubble--assistant .chat-bubble__content blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 0.75em; margin: 0.5em 0; color: var(--muted);
}
.chat-bubble--assistant .chat-bubble__content a { color: var(--accent-dark); text-decoration: underline; }
.chat-bubble--assistant .chat-bubble__content table {
  border-collapse: collapse; margin: 0.5em 0; font-size: 0.9em;
}
.chat-bubble--assistant .chat-bubble__content th,
.chat-bubble--assistant .chat-bubble__content td {
  border: 1px solid var(--border); padding: 0.375em 0.625em;
}
.chat-bubble--assistant .chat-bubble__content th { background: var(--bg); font-weight: 600; }

/* Typing indicator */
.typing-indicator {
  align-self: flex-start; display: flex; gap: 4px;
  padding: 0.75rem 1rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 18px; border-bottom-left-radius: 6px;
}
.typing-indicator span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--muted);
  animation: typing 1.4s ease-in-out infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.15s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.3s; }
@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* Streaming cursor */
.chat-cursor {
  display: inline-block; width: 2px; height: 1em;
  background: var(--accent); margin-left: 2px;
  vertical-align: text-bottom;
  animation: cursorBlink 0.8s steps(2) infinite;
}
@keyframes cursorBlink { 0% { opacity: 1; } 50% { opacity: 0; } }

/* Chat input bar */
.chat-input-bar {
  display: flex; gap: 0.5rem; padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--border); background: var(--surface);
  flex-shrink: 0;
}
.chat-input {
  flex: 1; padding: 0.55rem 0.85rem;
  font-family: var(--font); font-size: 0.9rem;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg); resize: none;
  max-height: 120px; line-height: 1.4;
  transition: border-color 0.15s;
}
.chat-input:focus { outline: none; border-color: var(--accent); }
.chat-input:disabled { opacity: 0.6; }
.chat-send-btn { align-self: flex-end; }

/* Hide the global taskbar when chat is active */
.page-chat-active .taskbar { display: none; }

/* ─── Mobile ────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .hamburger { display: flex; align-items: center; justify-content: center; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    transform: translateX(-100%); transition: transform 0.25s ease;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .main { padding: 3.5rem 1rem 6rem; }
  .chat-page { height: calc(100vh - 3.5rem); margin: -3.5rem -1rem -6rem; }
  .chat-bubble { max-width: 88%; }
  .taskbar { left: 0; }
  .taskbar-row { padding: 0.6rem 1rem; }
  .team-grid { grid-template-columns: 1fr; }
}
