/* ============================================================
   Perfect Employee — Demo Dashboard Styles
   Dark operations center, 3-panel layout
   ============================================================ */

/* ── Dashboard Layout ──────────────────────────────────── */

.dash {
  display: flex;
  height: 100vh;
  overflow: hidden;
  background: var(--dash-bg);
  font-family: var(--font-sans);
}

.dash * {
  box-sizing: border-box;
}

/* ── Top Bar ──────────────────────────────────────────── */

.dash-topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--dash-topbar-height);
  background: var(--dash-panel-bg);
  border-bottom: 1px solid var(--dash-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-6);
  z-index: var(--z-sticky);
}

.dash-topbar-left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.dash-topbar-logo {
  font-weight: var(--weight-bold);
  font-size: var(--text-sm);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.dash-topbar-logo-icon {
  width: 22px;
  height: 22px;
  background: linear-gradient(135deg, var(--accent-primary), var(--color-emerald-400));
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-navy-950);
  font-weight: var(--weight-extrabold);
  font-size: var(--text-xs);
}

.dash-topbar-badge {
  font-size: var(--text-xs);
  padding: 1px 8px;
  background: var(--accent-primary-glow);
  color: var(--accent-primary);
  border-radius: var(--radius-full);
  font-weight: var(--weight-semibold);
}

.dash-topbar-right {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.dash-live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-primary);
  box-shadow: 0 0 8px var(--accent-primary);
  animation: pulse-glow 2s infinite;
}

.dash-live-text {
  font-size: var(--text-xs);
  color: var(--accent-primary);
  font-weight: var(--weight-semibold);
}

.dash-topbar-time {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* ── Sidebar ──────────────────────────────────────────── */

.dash-sidebar {
  position: fixed;
  top: var(--dash-topbar-height);
  left: 0;
  bottom: 0;
  width: var(--dash-sidebar-width);
  background: var(--dash-panel-bg);
  border-right: 1px solid var(--dash-border);
  display: flex;
  flex-direction: column;
  padding: var(--space-4);
  gap: var(--space-1);
  overflow-y: auto;
  z-index: var(--z-base);
}

.dash-nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-muted);
  transition: all var(--transition-fast);
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.dash-nav-item:hover {
  color: var(--text-primary);
  background: hsla(0, 0%, 100%, 0.04);
}

.dash-nav-item.active {
  color: var(--accent-primary);
  background: var(--accent-primary-glow);
  border: 1px solid hsla(var(--hue-emerald), 84%, 40%, 0.15);
}

.dash-nav-icon {
  font-size: var(--text-lg);
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}

.dash-nav-badge {
  margin-left: auto;
  font-size: var(--text-xs);
  padding: 1px 6px;
  border-radius: var(--radius-full);
  background: var(--accent-primary-glow);
  color: var(--accent-primary);
  font-weight: var(--weight-bold);
}

.dash-sidebar-divider {
  height: 1px;
  background: var(--dash-border);
  margin: var(--space-3) 0;
}

/* ── Main Content Area ────────────────────────────────── */

.dash-main {
  position: fixed;
  top: var(--dash-topbar-height);
  left: var(--dash-sidebar-width);
  right: var(--dash-detail-width);
  bottom: 0;
  overflow-y: auto;
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  background: var(--dash-bg);
}

/* ── Stat Cards Row ───────────────────────────────────── */

.dash-stat-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-3);
}

.dash-stat-card {
  background: var(--dash-panel-bg);
  border: 1px solid var(--dash-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
}

.dash-stat-card-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-1);
}

.dash-stat-card-val {
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
  font-family: var(--font-mono);
}

.dash-stat-card-change {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  margin-top: var(--space-1);
}

.dash-stat-card-change.up { color: var(--status-success); }
.dash-stat-card-change.down { color: var(--accent-secondary); }

/* ── Main Panel (Inbox / Contact List) ────────────────── */

.dash-panel {
  flex: 1;
  background: var(--dash-panel-bg);
  border: 1px solid var(--dash-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.dash-panel-header {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--dash-border);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dash-panel-count {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-weight: var(--weight-normal);
}

.dash-contact-list {
  flex: 1;
  overflow-y: auto;
}

.dash-contact-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--dash-border);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.dash-contact-item:hover {
  background: hsla(0, 0%, 100%, 0.03);
}

.dash-contact-item.active {
  background: var(--accent-primary-glow);
  border-left: 3px solid var(--accent-primary);
}

.dash-contact-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

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

.dash-contact-preview {
  font-size: var(--text-xs);
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 280px;
}

.dash-contact-meta {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
}

.dash-contact-time {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.dash-contact-stage {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  font-weight: var(--weight-semibold);
  white-space: nowrap;
}

/* ── Detail Panel (Right) ─────────────────────────────── */

.dash-detail {
  position: fixed;
  top: var(--dash-topbar-height);
  right: 0;
  bottom: 0;
  width: var(--dash-detail-width);
  background: var(--dash-panel-bg);
  border-left: 1px solid var(--dash-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.dash-detail-header {
  padding: var(--space-4);
  border-bottom: 1px solid var(--dash-border);
}

.dash-detail-name {
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
  margin-bottom: var(--space-1);
}

.dash-detail-subtitle {
  font-size: var(--text-xs);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/* ── Conversation Thread ──────────────────────────────── */

.dash-thread {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.dash-msg {
  font-size: var(--text-sm);
  line-height: var(--leading-snug);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  max-width: 85%;
  position: relative;
}

.dash-msg.customer {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  align-self: flex-start;
  border-bottom-left-radius: var(--radius-sm);
}

.dash-msg.sage {
  background: hsla(var(--hue-emerald), 84%, 40%, 0.1);
  color: var(--text-primary);
  align-self: flex-end;
  border: 1px solid hsla(var(--hue-emerald), 84%, 40%, 0.15);
  border-bottom-right-radius: var(--radius-sm);
}

.dash-msg-time {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: var(--space-1);
  font-family: var(--font-mono);
}

.dash-msg.customer .dash-msg-time {
  text-align: left;
}

.dash-msg.sage .dash-msg-time {
  text-align: right;
}

/* ── Simulator Input ──────────────────────────────────── */

.dash-simulator {
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--dash-border);
  display: flex;
  gap: var(--space-2);
}

.dash-simulator-input {
  flex: 1;
  padding: var(--space-2) var(--space-3);
  background: var(--bg-tertiary);
  border: 1px solid var(--dash-border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--text-sm);
  font-family: var(--font-sans);
}

.dash-simulator-input::placeholder {
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.dash-simulator-input:focus {
  outline: none;
  border-color: var(--border-accent);
}

.dash-simulator-btn {
  padding: var(--space-2) var(--space-4);
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-primary-hover));
  color: var(--text-on-accent);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.dash-simulator-btn:hover {
  box-shadow: var(--shadow-glow-emerald);
}

.dash-simulator-btn:active {
  transform: scale(0.97);
}

/* ── Empty State ──────────────────────────────────────── */

.dash-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  color: var(--text-muted);
  padding: var(--space-8);
}

.dash-empty-icon {
  font-size: var(--text-5xl);
  opacity: 0.4;
}

.dash-empty-text {
  font-size: var(--text-base);
  text-align: center;
  line-height: var(--leading-relaxed);
  max-width: 240px;
}

/* ── Kanban Pipeline View ─────────────────────────────── */

.dash-kanban {
  display: flex;
  gap: var(--space-3);
  overflow-x: auto;
  padding-bottom: var(--space-4);
}

.kanban-col {
  flex: 0 0 220px;
  background: var(--bg-tertiary);
  border: 1px solid var(--dash-border);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
}

.kanban-col-header {
  padding: var(--space-3);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--text-secondary);
  border-bottom: 1px solid var(--dash-border);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.kanban-col-count {
  margin-left: auto;
  color: var(--text-muted);
  font-weight: var(--weight-normal);
}

.kanban-col-body {
  flex: 1;
  padding: var(--space-2);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-height: 100px;
}

.kanban-card {
  background: var(--dash-panel-bg);
  border: 1px solid var(--dash-border);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: var(--text-sm);
}

.kanban-card:hover {
  border-color: var(--border-accent);
}

.kanban-card-name {
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  margin-bottom: 2px;
}

.kanban-card-suburb {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* ── Calendar View ────────────────────────────────────── */

.dash-cal-week {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: var(--space-2);
}

.dash-cal-day {
  background: var(--bg-tertiary);
  border: 1px solid var(--dash-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.dash-cal-day-header {
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--text-secondary);
  border-bottom: 1px solid var(--dash-border);
  text-align: center;
}

.dash-cal-day-body {
  padding: var(--space-2);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.dash-cal-event {
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  font-size: 10px;
  font-weight: var(--weight-medium);
  cursor: pointer;
}

.dash-cal-event.confirmed {
  background: hsla(var(--hue-emerald), 84%, 40%, 0.15);
  color: var(--accent-primary);
  border-left: 2px solid var(--accent-primary);
}

.dash-cal-event.pending {
  background: var(--status-warning-bg);
  color: var(--status-warning);
  border-left: 2px solid var(--status-warning);
}

/* ── Stats / Charts ────────────────────────────────────── */

.dash-charts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}

.dash-chart-card {
  background: var(--dash-panel-bg);
  border: 1px solid var(--dash-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
}

.dash-chart-card h4 {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-secondary);
  margin-bottom: var(--space-4);
}

.dash-chart-bars {
  display: flex;
  align-items: flex-end;
  gap: var(--space-3);
  height: 120px;
  padding-top: var(--space-2);
}

.dash-chart-bar-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
  height: 100%;
  justify-content: flex-end;
}

.dash-chart-bar {
  width: 100%;
  max-width: 40px;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  background: linear-gradient(180deg, var(--accent-primary), hsla(var(--hue-emerald), 84%, 40%, 0.4));
  transition: height var(--transition-slow);
  min-height: 4px;
}

.dash-chart-bar-label {
  font-size: 10px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.dash-chart-bar-day {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
}

/* ── Templates Panel ──────────────────────────────────── */

.dash-templates-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  overflow-y: auto;
}

.dash-template-item {
  padding: var(--space-3) var(--space-4);
  background: var(--bg-tertiary);
  border: 1px solid var(--dash-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.dash-template-item:hover {
  border-color: var(--border-strong);
  background: var(--bg-surface);
}

.dash-template-name {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  margin-bottom: var(--space-1);
}

.dash-template-trigger {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.dash-template-preview {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  margin-top: var(--space-2);
  padding: var(--space-2);
  background: hsla(0, 0%, 100%, 0.02);
  border-radius: var(--radius-sm);
  line-height: var(--leading-snug);
  font-style: italic;
}

/* ── Overlay / Toast ──────────────────────────────────── */

.dash-toast {
  position: fixed;
  bottom: var(--space-6);
  right: calc(var(--dash-detail-width) + var(--space-6));
  padding: var(--space-3) var(--space-5);
  background: var(--accent-primary);
  color: var(--text-on-accent);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: var(--z-toast);
  opacity: 0;
  transform: translateY(8px);
  transition: all var(--transition-base);
}

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

/* ── Detail Panel Close Button ────────────────────────── */

.dash-detail-close {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  border: 1px solid var(--dash-border);
  color: var(--text-muted);
  font-size: var(--text-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.dash-detail-close:hover {
  color: var(--text-primary);
  border-color: var(--border-strong);
}

/* ── Welcome Overlay ──────────────────────────────────── */

.welcome-overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 12, 24, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-base);
}

.welcome-overlay.show {
  opacity: 1;
  pointer-events: all;
}

.welcome-card {
  text-align: center;
  padding: var(--space-12);
  max-width: 480px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-5);
}

.welcome-icon {
  font-size: 48px;
}

.welcome-title {
  font-size: var(--text-3xl);
  font-weight: var(--weight-extrabold);
  color: var(--text-primary);
}

.welcome-sub {
  font-size: var(--text-base);
  color: var(--text-muted);
  line-height: var(--leading-relaxed);
}

.welcome-progress {
  width: 200px;
  height: 2px;
  background: var(--dash-border);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-top: var(--space-4);
}

.welcome-progress-bar {
  height: 100%;
  background: var(--accent-primary);
  width: 0%;
  animation: welcomeFill 4s ease forwards;
}

@keyframes welcomeFill {
  to { width: 100%; }
}

/* ── Exit demo button ─────────────────────────────────── */

.dash-exit {
  font-size: var(--text-xs);
  color: var(--text-muted);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  border: 1px solid var(--dash-border);
  cursor: pointer;
  transition: all var(--transition-fast);
  background: var(--bg-tertiary);
}

.dash-exit:hover {
  color: var(--text-primary);
  border-color: var(--border-strong);
}

/* ── Responsive ────────────────────────────────────────── */

@media (max-width: 1024px) {
  :root {
    --dash-sidebar-width: 60px;
    --dash-detail-width: 320px;
  }

  .dash-nav-label,
  .dash-nav-badge {
    display: none;
  }
  .dash-nav-item {
    justify-content: center;
    padding: var(--space-3);
  }
  .dash-nav-icon {
    margin: 0;
  }
}

@media (max-width: 768px) {
  .dash-sidebar {
    display: none;
  }

  .dash-main {
    left: 0;
    right: 0;
  }

  .dash-detail {
    display: none;
    /* On mobile, detail slides in via JS */
    position: fixed;
    inset: var(--dash-topbar-height) 0 0 0;
    width: 100%;
    z-index: var(--z-overlay);
  }

  .dash-detail.mobile-open {
    display: flex;
  }

  .dash-stat-row {
    grid-template-columns: 1fr 1fr;
  }

  .dash-kanban {
    flex-direction: column;
  }

  .kanban-col {
    flex: none;
  }

  .dash-cal-week {
    grid-template-columns: 1fr;
  }

  .dash-charts {
    grid-template-columns: 1fr;
  }
}
