/* ============================================================
   Bryan's Email Command Center — Main Layout
   ============================================================ */

@import url('variables.css');

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

html { height: 100%; font-size: 14px; }

body {
  font-family: var(--font-family);
  font-size: var(--text-base);
  color: var(--text-primary);
  background: var(--bg-primary);
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* ── Scrollbars ──────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--scrollbar-track); }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* ── App Shell ───────────────────────────────────────────── */
#app {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* ── Top Bar ─────────────────────────────────────────────── */
#topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--topbar-height);
  background: var(--accent);
  display: flex;
  align-items: center;
  padding: 0 var(--space-4);
  z-index: 100;
  gap: var(--space-3);
  box-shadow: var(--shadow-sm);
}

#topbar .app-title {
  color: #fff;
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  letter-spacing: -0.2px;
  flex: 1;
}

#topbar .topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.topbar-btn {
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: var(--text-sm);
  font-family: var(--font-family);
  display: flex;
  align-items: center;
  gap: var(--space-1);
  transition: background var(--transition-fast);
}
.topbar-btn:hover { background: rgba(255,255,255,0.25); }
.topbar-btn svg { width: 16px; height: 16px; }

/* Auth badge in topbar */
#auth-badge {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: rgba(255,255,255,0.9);
  font-size: var(--text-sm);
}
#auth-badge .status-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: #92c353;
}
#auth-badge .status-dot.offline { background: #d13438; }
#auth-badge .status-dot.pending { background: #f5a623; animation: pulse 1.5s infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ── Sidebar ─────────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width var(--transition-base);
  padding-top: var(--topbar-height);
  flex-shrink: 0;
}

#sidebar.collapsed {
  width: var(--sidebar-collapsed);
  min-width: var(--sidebar-collapsed);
}

.sidebar-section {
  padding: var(--space-2) 0;
}

.sidebar-section-label {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: var(--space-3) var(--space-4) var(--space-1);
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-4);
  cursor: pointer;
  border-radius: 0;
  transition: background var(--transition-fast);
  color: var(--text-primary);
  text-decoration: none;
  position: relative;
  white-space: nowrap;
  overflow: hidden;
  min-height: 36px;
  user-select: none;
}

.sidebar-item:hover {
  background: var(--bg-sidebar-hover);
}

.sidebar-item.active {
  background: var(--bg-sidebar-active);
  color: var(--accent);
  font-weight: var(--weight-semibold);
}

.sidebar-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 3px;
  background: var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.sidebar-item.disabled {
  opacity: 0.45;
  cursor: default;
  pointer-events: none;
}

.sidebar-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: var(--icon-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-item.active .sidebar-icon { color: var(--accent); }

.sidebar-label {
  font-size: var(--text-base);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-badge {
  background: var(--accent);
  color: #fff;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  padding: 1px var(--space-2);
  border-radius: var(--radius-full);
  min-width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-badge.urgent { background: var(--urgent); }
.sidebar-badge.muted  { background: var(--border-default); color: var(--text-secondary); }

#sidebar-footer {
  margin-top: auto;
  border-top: 1px solid var(--border-subtle);
  padding: var(--space-2) 0;
}

/* ── Main Content Area ───────────────────────────────────── */
#main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-top: var(--topbar-height);
  min-width: 0;
}

#content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--space-6);
}

/* ── Page Header ─────────────────────────────────────────── */
.page-header {
  margin-bottom: var(--space-6);
}

.page-title {
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  margin-bottom: var(--space-1);
}

.page-subtitle {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

/* ── Cards ───────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.card-header {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.card-title {
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
}

.card-body {
  padding: var(--space-5);
}

/* ── Grid ────────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-4); }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--space-4); }

/* ── Stat Card ───────────────────────────────────────────── */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: box-shadow var(--transition-fast), transform var(--transition-fast);
  position: relative;
  overflow: hidden;
}

.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.stat-card .stat-label {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  font-weight: var(--weight-medium);
  margin-bottom: var(--space-2);
}

.stat-card .stat-count {
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
  line-height: 1;
  margin-bottom: var(--space-2);
}

.stat-card .stat-desc {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
}

.stat-card.urgent  { border-left: 4px solid var(--urgent); }
.stat-card.high    { border-left: 4px solid var(--high); }
.stat-card.normal  { border-left: 4px solid var(--normal); }
.stat-card.low     { border-left: 4px solid var(--low); }
.stat-card.noise   { border-left: 4px solid var(--noise); }

.stat-card.urgent  .stat-count { color: var(--urgent); }
.stat-card.high    .stat-count { color: var(--high); }
.stat-card.normal  .stat-count { color: var(--normal); }
.stat-card.low     .stat-count { color: var(--low); }
.stat-card.noise   .stat-count { color: var(--noise); }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-family: var(--font-family);
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-primary:active:not(:disabled) { background: var(--accent-active); }

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border-color: var(--border-default);
}
.btn-secondary:hover:not(:disabled) { background: var(--bg-sidebar-hover); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}
.btn-ghost:hover:not(:disabled) { background: var(--bg-sidebar-hover); color: var(--text-primary); }

.btn-danger {
  background: var(--urgent);
  color: #fff;
  border-color: var(--urgent);
}

.btn-sm {
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-sm);
}

.btn-icon {
  padding: var(--space-2);
  border-radius: var(--radius-md);
}

/* ── Message List ────────────────────────────────────────── */
.message-list { display: flex; flex-direction: column; }

.message-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: background var(--transition-fast);
  position: relative;
}

.message-item:hover { background: var(--bg-tertiary); }
.message-item.selected { background: var(--accent-subtle); }
.message-item.unread .message-subject { font-weight: var(--weight-semibold); }

.message-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  flex-shrink: 0;
}

.message-content { flex: 1; min-width: 0; }

.message-sender {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.message-subject {
  font-size: var(--text-base);
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}

.message-preview {
  font-size: var(--text-sm);
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.message-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-1);
  flex-shrink: 0;
}

.message-time {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  white-space: nowrap;
}

/* ── Triage badge ────────────────────────────────────────── */
.triage-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  border: 1px solid;
}

.triage-badge.urgent { color: var(--urgent); background: var(--urgent-bg); border-color: var(--urgent-border); }
.triage-badge.high   { color: var(--high);   background: var(--high-bg);   border-color: var(--high-border); }
.triage-badge.normal { color: var(--normal); background: var(--normal-bg); border-color: var(--normal-border); }
.triage-badge.low    { color: var(--low);    background: var(--low-bg);    border-color: var(--low-border); }
.triage-badge.noise  { color: var(--noise);  background: var(--noise-bg);  border-color: var(--noise-border); }

/* ── Event / Calendar Item ───────────────────────────────── */
.event-item {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border-subtle);
}

.event-time-col {
  width: 72px;
  flex-shrink: 0;
  text-align: right;
}

.event-time-start {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
}

.event-time-end {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
}

.event-bar {
  width: 3px;
  border-radius: var(--radius-full);
  background: var(--accent);
  flex-shrink: 0;
  align-self: stretch;
  min-height: 40px;
}

.event-details { flex: 1; min-width: 0; }

.event-title {
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  color: var(--text-primary);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.event-location {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

/* ── Auth Setup Screen ───────────────────────────────────── */
#auth-setup {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
}

.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  padding: var(--space-12) var(--space-10);
  max-width: 480px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-lg);
}

.auth-logo {
  width: 64px;
  height: 64px;
  margin: 0 auto var(--space-6);
  background: var(--accent);
  border-radius: var(--radius-xl);
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-title {
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
  margin-bottom: var(--space-2);
}

.auth-subtitle {
  color: var(--text-secondary);
  font-size: var(--text-base);
  margin-bottom: var(--space-8);
  line-height: 1.5;
}

.auth-code-display {
  background: var(--bg-primary);
  border: 2px solid var(--accent);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  margin: var(--space-6) 0;
}

.auth-user-code {
  font-family: var(--font-mono);
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
  color: var(--accent);
  letter-spacing: 4px;
}

.auth-url {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-top: var(--space-2);
}

.auth-url a {
  color: var(--accent);
  text-decoration: none;
}

.auth-url a:hover { text-decoration: underline; }

.auth-status {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-top: var(--space-4);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
}

/* ── Loading / Skeleton ──────────────────────────────────── */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--border-subtle) 25%,
    var(--bg-sidebar-hover) 50%,
    var(--border-subtle) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-md);
}

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-line {
  height: 14px;
  margin-bottom: var(--space-2);
  border-radius: var(--radius-sm);
}

.skeleton-line.short { width: 40%; }
.skeleton-line.medium { width: 65%; }
.skeleton-line.long { width: 100%; }

/* ── Toast Notifications ─────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  max-width: 360px;
  font-size: var(--text-sm);
  pointer-events: all;
  animation: slide-in 200ms ease;
  border-left: 4px solid var(--accent);
}

.toast.success { border-left-color: var(--low); }
.toast.error   { border-left-color: var(--urgent); }
.toast.warning { border-left-color: var(--high); }

@keyframes slide-in {
  from { transform: translateX(20px); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

/* ── Divider ─────────────────────────────────────────────── */
.divider {
  height: 1px;
  background: var(--border-subtle);
  margin: var(--space-4) 0;
}

/* ── Empty State ─────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: var(--space-12) var(--space-6);
  color: var(--text-tertiary);
}

.empty-state svg {
  width: 48px;
  height: 48px;
  margin-bottom: var(--space-4);
  opacity: 0.5;
}

.empty-state h3 {
  font-size: var(--text-md);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
  margin-bottom: var(--space-2);
}

.empty-state p {
  font-size: var(--text-sm);
  line-height: 1.5;
}

/* ── Spinner ─────────────────────────────────────────────── */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-default);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 600ms linear infinite;
  flex-shrink: 0;
}
.spinner.sm { width: 14px; height: 14px; }
.spinner.lg { width: 32px; height: 32px; }

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Utilities ───────────────────────────────────────────── */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mb-4 { margin-bottom: var(--space-4); }
.text-sm { font-size: var(--text-sm); }
.text-xs { font-size: var(--text-xs); }
.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }
.font-semibold { font-weight: var(--weight-semibold); }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

/* ── Folder Tree ─────────────────────────────────────────── */
.sidebar-folders-section {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
}

.folder-item {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding: 5px var(--space-3) 5px 12px;
  cursor: pointer;
  transition: background var(--transition-fast);
  color: var(--text-primary);
  font-size: var(--text-sm);
  user-select: none;
  white-space: nowrap;
  overflow: hidden;
  position: relative;
  min-height: 28px;
}

.folder-item:hover { background: var(--bg-sidebar-hover); }

.folder-item.active {
  background: var(--bg-sidebar-active);
  color: var(--accent);
  font-weight: var(--weight-semibold);
}

.folder-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 3px;
  bottom: 3px;
  width: 3px;
  background: var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.folder-arrow {
  width: 14px;
  flex-shrink: 0;
  color: var(--text-tertiary);
  font-size: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.folder-arrow.invisible { visibility: hidden; }

.folder-icon {
  flex-shrink: 0;
  font-size: 13px;
  line-height: 1;
}

.folder-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: var(--text-sm);
}

.folder-unread {
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: var(--weight-semibold);
  padding: 1px 5px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
  min-width: 18px;
  text-align: center;
  line-height: 16px;
}

.folder-primary-dot {
  color: var(--accent);
  font-size: 8px;
  flex-shrink: 0;
}

/* ── Triage Stat Bar ─────────────────────────────────────── */
.triage-stat-bar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.stat-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px var(--space-3);
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  border: 1px solid var(--border-default);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-family: var(--font-family);
  white-space: nowrap;
}

.stat-chip:hover { background: var(--bg-sidebar-hover); color: var(--text-primary); }

.stat-chip.active,
.stat-chip:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.stat-chip.urgent        { border-color: var(--urgent-border); color: var(--urgent); background: var(--urgent-bg); }
.stat-chip.urgent.active { background: var(--urgent); color: #fff; }

.stat-chip.high          { border-color: var(--high-border); color: var(--high); background: var(--high-bg); }
.stat-chip.high.active   { background: var(--high); color: #fff; }

.stat-chip.personal          { border-color: var(--normal-border); color: var(--normal); background: var(--normal-bg); }
.stat-chip.personal.active   { background: var(--normal); color: #fff; }

.stat-chip.draft         { border-color: var(--low-border); color: var(--low); background: var(--low-bg); }
.stat-chip.muted         { border-color: var(--border-subtle); color: var(--text-tertiary); background: var(--bg-primary); cursor: default; }

/* ── Triage Filter Bar ───────────────────────────────────── */
.triage-filter-bar {
  display: flex;
  gap: var(--space-2);
  align-items: center;
}

.triage-filter-btn {
  padding: 4px var(--space-4);
  border-radius: var(--radius-full);
  border: 1px solid var(--border-default);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-family: var(--font-family);
  font-weight: var(--weight-medium);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.triage-filter-btn:hover { background: var(--bg-sidebar-hover); color: var(--text-primary); }
.triage-filter-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ── Triage Section Header ───────────────────────────────── */
.triage-section-header {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: var(--space-3) var(--space-4) var(--space-2);
  color: var(--text-tertiary);
  border-bottom: 1px solid var(--border-subtle);
  margin-top: var(--space-2);
}

.triage-section-header:first-child { margin-top: 0; }
.business-header { color: var(--normal); }
.personal-header { color: var(--low); }

/* ── Triage Card ─────────────────────────────────────────── */
.triage-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-left: 4px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  margin-bottom: var(--space-3);
  transition: box-shadow var(--transition-fast), transform var(--transition-fast);
  cursor: default;
}

.triage-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.triage-card.level-urgent   { border-left-color: var(--urgent); }
.triage-card.level-high     { border-left-color: var(--high); }
.triage-card.level-important{ border-left-color: var(--high); }
.triage-card.level-normal   { border-left-color: var(--normal); }
.triage-card.level-low      { border-left-color: var(--low); }
.triage-card.level-noise    { border-left-color: var(--noise); opacity: 0.75; }

.triage-card-header {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
}

.triage-card-meta {
  flex: 1;
  min-width: 0;
}

.triage-card-sender {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: 3px;
  flex-wrap: wrap;
}

.sender-name {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
}

.triage-level-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px var(--space-2);
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: var(--weight-semibold);
  border: 1px solid;
  text-transform: lowercase;
}

.triage-level-badge.urgent   { color: var(--urgent); background: var(--urgent-bg); border-color: var(--urgent-border); }
.triage-level-badge.high     { color: var(--high);   background: var(--high-bg);   border-color: var(--high-border); }
.triage-level-badge.important{ color: var(--high);   background: var(--high-bg);   border-color: var(--high-border); }
.triage-level-badge.normal   { color: var(--normal); background: var(--normal-bg); border-color: var(--normal-border); }
.triage-level-badge.low      { color: var(--low);    background: var(--low-bg);    border-color: var(--low-border); }
.triage-level-badge.noise    { color: var(--noise);  background: var(--noise-bg);  border-color: var(--noise-border); }

.personal-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px var(--space-2);
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: var(--weight-medium);
  background: var(--low-bg);
  color: var(--low);
  border: 1px solid var(--low-border);
}

.triage-card-subject {
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  color: var(--text-primary);
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.triage-card-preview {
  font-size: var(--text-sm);
  color: var(--text-tertiary);
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.4;
}

.triage-reasoning {
  margin-top: var(--space-2);
  font-size: var(--text-xs);
  color: var(--text-secondary);
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  line-height: 1.4;
  font-style: italic;
}

.triage-card-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-2);
  flex-shrink: 0;
  min-width: 70px;
}

.triage-card-actions {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-3);
  flex-wrap: wrap;
}

/* ── Folder Badge (shows which folder an email is in) ────── */
.folder-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--space-2);
  border-radius: var(--radius-md);
  font-size: 11px;
  font-weight: var(--weight-medium);
  background: var(--bg-primary);
  color: var(--text-tertiary);
  border: 1px solid var(--border-subtle);
  white-space: nowrap;
}

/* ── Extra-small button variant ──────────────────────────── */
.btn-xs {
  padding: 2px var(--space-2);
  font-size: var(--text-xs);
  border-radius: var(--radius-md);
}

/* ── Loading spinner (centered) ──────────────────────────── */
.loading-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border-default);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 600ms linear infinite;
  margin: var(--space-8) auto;
}

/* ── View Header (folder view) ───────────────────────────── */
.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
  gap: var(--space-3);
}

.view-header h2 {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
}

/* ── Modal ───────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
  animation: fade-in 150ms ease;
}

@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 640px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slide-up 150ms ease;
}

@keyframes slide-up {
  from { transform: translateY(12px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

.modal-header {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.modal-title {
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  white-space: nowrap;
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-5);
}

.modal-textarea {
  width: 100%;
  min-height: 220px;
  padding: var(--space-3);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--bg-input);
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: var(--text-base);
  line-height: 1.5;
  resize: vertical;
  outline: none;
  transition: border-color var(--transition-fast);
}

.modal-textarea:focus { border-color: var(--accent); }

.modal-footer {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
}

/* ── Form inputs (used in settings) ─────────────────────── */
.form-input {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--bg-input);
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: var(--text-base);
  outline: none;
  transition: border-color var(--transition-fast);
}

.form-input:focus { border-color: var(--accent); }

/* ── Natasha Sidebar Icon ────────────────────────────────── */
.natasha-icon {
  width: 20px;
  height: 20px;
  background: linear-gradient(135deg, #7719aa, #0078d4);
  border-radius: var(--radius-full);
  color: #fff;
  font-weight: var(--weight-bold);
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ── Chat Shell ──────────────────────────────────────────── */
.chat-shell {
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--topbar-height));
  margin: calc(-1 * var(--space-6));  /* bleed to edges */
}

.chat-topbar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-card);
  flex-shrink: 0;
}

.natasha-avatar-sm {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, #7719aa, #0078d4);
  border-radius: var(--radius-full);
  color: #fff;
  font-weight: var(--weight-bold);
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.chat-name {
  font-weight: var(--weight-semibold);
  font-size: var(--text-base);
  color: var(--text-primary);
}

.chat-status {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
}

.chat-status.thinking {
  color: var(--accent);
  animation: pulse 1.2s infinite;
}

/* ── Chat Messages ───────────────────────────────────────── */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4) var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  background: var(--bg-primary);
}

.chat-message {
  display: flex;
  gap: var(--space-2);
  max-width: 82%;
}

.chat-message.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.chat-message.assistant {
  align-self: flex-start;
}

.chat-avatar {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: var(--weight-bold);
  color: #fff;
  background: linear-gradient(135deg, #7719aa, #0078d4);
  margin-top: 2px;
}

.chat-message.user .chat-avatar {
  background: var(--accent);
}

.chat-bubble {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  font-size: var(--text-base);
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.user .chat-bubble {
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: var(--radius-sm);
}

.assistant .chat-bubble {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  border-bottom-left-radius: var(--radius-sm);
}

/* Action chips shown below Natasha's messages */
.chat-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-2);
  margin-left: 36px;
}

.chat-action-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px var(--space-3);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  background: var(--low-bg);
  color: var(--low);
  border: 1px solid var(--low-border);
}

/* Typing indicator */
.chat-typing {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) 0;
  font-size: var(--text-sm);
  color: var(--text-tertiary);
  font-style: italic;
}

.typing-dots {
  display: flex;
  gap: 3px;
}

.typing-dots span {
  width: 5px;
  height: 5px;
  background: var(--text-tertiary);
  border-radius: var(--radius-full);
  animation: bounce 1.2s infinite;
}

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

@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); }
  40%           { transform: translateY(-5px); }
}

/* ── Chat Input Area ─────────────────────────────────────── */
.chat-input-area {
  display: flex;
  gap: var(--space-2);
  align-items: flex-end;
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-card);
  flex-shrink: 0;
}

.chat-input {
  flex: 1;
  resize: none;
  min-height: 40px;
  max-height: 120px;
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-full);
  font-family: var(--font-family);
  font-size: var(--text-base);
  background: var(--bg-input);
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--transition-fast);
  line-height: 1.5;
  overflow-y: auto;
}

.chat-input:focus { border-color: var(--accent); }

/* ── Mic / Voice Button ──────────────────────────────────── */
.voice-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-default);
  background: var(--bg-card);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  flex-shrink: 0;
  transition: all var(--transition-fast);
  color: var(--text-secondary);
}

.voice-btn:hover { background: var(--bg-sidebar-hover); color: var(--text-primary); }
.voice-btn.recording {
  background: var(--urgent);
  border-color: var(--urgent);
  color: #fff;
  animation: pulse 1s infinite;
}
.voice-btn.speaking {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ── Natasha's Desk Items ────────────────────────────────── */
.desk-item {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  margin-bottom: var(--space-3);
  transition: box-shadow var(--transition-fast);
}

.desk-item:hover { box-shadow: var(--shadow-md); }

.desk-item.priority-high { border-left: 4px solid var(--high); }
.desk-item.priority-normal { border-left: 4px solid var(--normal); }
.desk-item.priority-low { border-left: 4px solid var(--border-default); }

.desk-item-header {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  margin-bottom: var(--space-2);
}

.desk-item-type {
  font-size: 18px;
  flex-shrink: 0;
  line-height: 1;
  margin-top: 1px;
}

.desk-item-title {
  flex: 1;
  font-weight: var(--weight-semibold);
  font-size: var(--text-base);
  color: var(--text-primary);
  line-height: 1.3;
}

.desk-item-meta {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  margin-top: 2px;
}

.desk-item-desc {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-bottom: var(--space-3);
  line-height: 1.5;
}

.desk-item-actions {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

/* ── Kanban Board ────────────────────────────────────────── */
.kanban-page {
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--topbar-height) - var(--space-6) - var(--space-6));
  overflow: hidden;
}

.kanban-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
  margin-bottom: var(--space-4);
  flex-shrink: 0;
}

.kanban-board {
  display: flex;
  flex-direction: row;
  gap: var(--space-4);
  overflow-x: auto;
  overflow-y: hidden;
  flex: 1;
  padding-bottom: var(--space-4);
  align-items: flex-start;
}

.kanban-column {
  min-width: 272px;
  max-width: 272px;
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  max-height: 100%;
  flex-shrink: 0;
}

.kanban-column-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-3) var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.kanban-column-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.kanban-column-name {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  flex: 1;
}

.kanban-column-count {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  background: var(--bg-sidebar-hover);
  border-radius: var(--radius-full);
  padding: 1px 7px;
  font-weight: var(--weight-medium);
}

.kanban-add-col-btn {
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 0 2px;
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast);
}

.kanban-add-col-btn:hover { color: var(--accent); }

.kanban-column-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-2);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-height: 60px;
}

.kanban-column-body.drag-over {
  background: var(--accent-subtle, rgba(99,102,241,0.06));
  border-radius: 0 0 var(--radius-xl) var(--radius-xl);
}

.kanban-empty {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  text-align: center;
  padding: var(--space-4) 0;
}

/* ── Kanban Card ─────────────────────────────────────────── */
.kanban-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-left: 3px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: var(--space-3);
  cursor: pointer;
  transition: box-shadow var(--transition-fast), transform var(--transition-fast);
  user-select: none;
}

.kanban-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.kanban-card.dragging {
  opacity: 0.5;
  box-shadow: var(--shadow-lg);
}

.kanban-card.priority-urgent { border-left-color: var(--urgent); }
.kanban-card.priority-high   { border-left-color: var(--high); }
.kanban-card.priority-normal { border-left-color: var(--normal); }
.kanban-card.priority-low    { border-left-color: var(--low); }

.kanban-card-labels {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 6px;
}

.kanban-label {
  font-size: 10px;
  font-weight: var(--weight-medium);
  color: var(--accent);
  background: var(--accent-subtle, rgba(99,102,241,0.1));
  border-radius: var(--radius-full);
  padding: 1px 7px;
  white-space: nowrap;
}

.kanban-card-title {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-primary);
  line-height: 1.4;
  margin-bottom: var(--space-2);
}

.kanban-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.kanban-card-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.assignee-pill {
  font-size: 11px;
  font-weight: var(--weight-semibold);
  background: var(--bg-sidebar-hover);
  color: var(--text-secondary);
  border-radius: var(--radius-full);
  padding: 1px 8px;
}

.due-date {
  font-size: 11px;
  color: var(--text-tertiary);
}

.due-date.overdue {
  color: var(--urgent);
  font-weight: var(--weight-semibold);
}

.waiting-badge {
  font-size: 10px;
  border-radius: var(--radius-full);
  padding: 1px 7px;
  font-weight: var(--weight-medium);
}

.waiting-bryan   { background: rgba(99,102,241,0.12); color: #6366f1; }
.waiting-natasha { background: rgba(16,185,129,0.12); color: #10b981; }

.email-link-icon {
  font-size: 12px;
  color: var(--text-tertiary);
  flex-shrink: 0;
}

/* ── Kanban Card Modal ───────────────────────────────────── */
.kanban-modal-card {
  background: var(--bg-primary);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl, 0 20px 60px rgba(0,0,0,0.3));
  width: 820px;
  max-width: 95vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.kanban-modal-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.kanban-modal-title-input {
  flex: 1;
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  background: transparent;
  border: none;
  outline: none;
  padding: 4px 8px;
  border-radius: var(--radius-md);
  transition: background var(--transition-fast);
  font-family: var(--font-family);
}

.kanban-modal-title-input:focus {
  background: var(--bg-sidebar-hover);
}

.kanban-modal-body {
  display: grid;
  grid-template-columns: 1fr 220px;
  gap: 0;
  flex: 1;
  overflow: hidden;
}

.kanban-modal-main {
  overflow-y: auto;
  padding: var(--space-5);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.kanban-modal-sidebar {
  overflow-y: auto;
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.card-comments-section h4 {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-secondary);
  margin-bottom: var(--space-3);
}

.comment-item {
  border-left: 2px solid var(--border-subtle);
  padding-left: var(--space-3);
  margin-bottom: var(--space-3);
}

.comment-author {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--text-secondary);
  margin-bottom: 2px;
}

.comment-time {
  font-weight: var(--weight-normal);
  color: var(--text-tertiary);
}

.comment-body {
  font-size: var(--text-sm);
  color: var(--text-primary);
  white-space: pre-wrap;
}

.kanban-label-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--accent);
  background: var(--accent-subtle, rgba(99,102,241,0.1));
  border-radius: var(--radius-full);
  padding: 2px 8px;
}

.label-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-tertiary);
  font-size: 13px;
  line-height: 1;
  padding: 0;
}

.label-remove:hover { color: var(--urgent); }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
  #sidebar { width: var(--sidebar-collapsed); }
  .sidebar-label, .sidebar-section-label, .sidebar-badge { display: none; }
  .folder-label, .folder-unread, .folder-primary-dot { display: none; }
  #content { padding: var(--space-4); }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .triage-card-right { display: none; }
  .triage-filter-bar { flex-wrap: wrap; }
}
