/* ============================================================
   Mission Control — Wibil Labs Dashboard
   Linear-inspired design system
   Font: Inter (all weights)
   ============================================================ */

/* ─── CSS Variables ──────────────────────────────────────── */
:root {
  --color-green:     #22C55E;
  --color-warning:   #F59E0B;
  --color-yellow:    #F59E0B;
  --color-red:       #D4198A;
  --color-blue:      #3D72FF;
  --color-blue-light: #7AA8FF;
  --color-purple:    #7B2FBE;

  --color-green-dim:   rgba(34, 197, 94, 0.15);
  --color-warning-dim: rgba(245, 158, 11, 0.15);
  --color-red-dim:     rgba(212, 25, 138, 0.15);
  --color-blue-dim:    rgba(61, 114, 255, 0.20);

  --font-heading: 'Inter', sans-serif;
  --font-body:    'Inter', sans-serif;

  --radius:      8px;
  --radius-sm:   4px;
  --sidebar-w:   220px;
  --panel-pad:   20px;
}

/* ─── Dark Mode (default) ────────────────────────────────── */
[data-theme="dark"] {
  --bg:              #0D0D0D;
  --bg-sidebar:      #111111;
  --bg-surface:      #111111;
  --bg-hover:        rgba(255,255,255,0.03);
  --bg-active:       #1E1E1E;
  --nav-hover:       #1A1A1A;
  --text-primary:    #E5E5E5;
  --text-secondary:  #6B7280;
  --text-muted:      #6B7280;
  --border:          rgba(255,255,255,0.06);
  --border-strong:   rgba(255,255,255,0.10);
  --shadow:          none;
  --logo-color:      #E5E5E5;
}

/* ─── Light Mode ─────────────────────────────────────────── */
[data-theme="light"] {
  --bg:              #F8F9FA;
  --bg-sidebar:      #FFFFFF;
  --bg-surface:      #FFFFFF;
  --bg-hover:        #F3F4F6;
  --bg-active:       #F0F0F0;
  --nav-hover:       #F3F4F6;
  --text-primary:    #1A1A1A;
  --text-secondary:  #6B7280;
  --text-muted:      #6B7280;
  --border:          rgba(0,0,0,0.06);
  --border-strong:   rgba(0,0,0,0.10);
  --shadow:          0 1px 3px rgba(0,0,0,0.06);
  --logo-color:      #1A1A1A;
}

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

html {
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  transition: background 0.15s ease, color 0.15s ease;
}

/* ─── Sidebar ────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 16px 0;
  transition: background 0.15s ease;
}

.sidebar-top {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
}

.wibil-wordmark {
  height: 22px;
  width: auto;
  display: block;
  color: var(--logo-color);
  flex-shrink: 0;
}

.sidebar-label {
  font-size: 0.6875rem;
  font-weight: 400;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ─── Sidebar Nav ────────────────────────────────────────── */
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 0 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 12px;
  border: none;
  border-left: 2px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.1s ease, color 0.1s ease, border-color 0.1s ease;
  text-align: left;
}

.nav-item:hover {
  background: var(--nav-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--bg-active);
  color: var(--text-primary);
  border-left-color: var(--color-blue);
}

.nav-icon {
  font-size: 0.875rem;
  flex-shrink: 0;
  width: 20px;
  text-align: center;
}

.nav-text {
  white-space: nowrap;
}

/* ─── Sidebar Bottom ─────────────────────────────────────── */
.sidebar-bottom {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0 16px;
}

.theme-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.75rem;
  cursor: pointer;
  transition: background 0.1s ease;
}

.theme-toggle:hover {
  background: var(--nav-hover);
}

.toggle-label {
  font-size: 0.75rem;
}

[data-theme="dark"]  .icon-moon { color: var(--color-blue); }
[data-theme="light"] .icon-sun  { color: var(--color-blue); }
[data-theme="dark"]  .icon-sun  { display: none; }
[data-theme="light"] .icon-moon { display: none; }

.last-refresh {
  font-size: 0.6875rem;
  color: var(--text-muted);
  padding: 0 2px;
}

/* ─── Main Content ───────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ─── Today's Actions Strip ──────────────────────────────── */
.actions-strip {
  background: linear-gradient(135deg, #D4198A, #7B2FBE);
  padding: 10px 24px;
  flex-shrink: 0;
}

.strip-inner {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}

.strip-label {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  padding-top: 2px;
}

.strip-title {
  font-size: 0.5625rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #FFFFFF;
  white-space: nowrap;
}

.actions-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  list-style: none;
  flex: 1;
}

.action-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8125rem;
  color: rgba(255,255,255,0.9);
}

.action-badge {
  font-size: 0.5rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 3px;
  background: rgba(255,255,255,0.18);
  color: #FFFFFF;
  flex-shrink: 0;
}

/* ─── Panel Views ────────────────────────────────────────── */
.panel-view {
  display: none;
  flex-direction: column;
  flex: 1;
}

.panel-view.active {
  display: flex;
}

.panel {
  background: transparent;
  transition: background 0.15s ease;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px 12px;
  border-bottom: 1px solid var(--border);
}

.panel-title {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.panel-source, .panel-meta {
  font-size: 0.6875rem;
  color: var(--text-muted);
}

.panel-body {
  flex: 1;
  padding: 16px 24px;
  overflow-x: auto;
}

/* ─── Activity Feed ──────────────────────────────────────── */
.activity-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.activity-entry {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  transition: background 0.1s ease;
}

.activity-entry:hover {
  background: var(--bg-hover);
}

.activity-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 5px;
}

.activity-dot.dot-email   { background: var(--color-blue); box-shadow: 0 0 6px rgba(61,114,255,0.3); }
.activity-dot.dot-memory  { background: var(--color-purple); box-shadow: 0 0 6px rgba(123,47,190,0.3); }
.activity-dot.dot-error   { background: var(--color-red); box-shadow: 0 0 6px rgba(212,25,138,0.3); }
.activity-dot.dot-default { background: var(--text-muted); }

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

.activity-title {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.3;
}

.activity-detail {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-top: 2px;
  line-height: 1.3;
}

.activity-time {
  font-size: 0.6875rem;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
  padding-top: 2px;
  font-variant-numeric: tabular-nums;
}

.activity-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* ─── Data Tables (shared) ───────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.data-table th {
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-muted);
  text-align: left;
  padding: 6px 10px 8px;
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table tr:hover td {
  background: var(--bg-hover);
}

.cell-primary {
  font-size: 0.875rem;
  color: var(--text-primary);
}

.cell-muted {
  color: var(--text-muted);
}

.cell-warning {
  color: var(--color-warning);
}

/* ─── Status Dots ────────────────────────────────────────── */
.status-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-right: 8px;
  vertical-align: middle;
}

.status-dot.dot-green  { background: #22C55E; box-shadow: 0 0 6px rgba(34,197,94,0.3); }
.status-dot.dot-yellow { background: var(--color-warning); }
.status-dot.dot-red    { background: var(--color-red); box-shadow: 0 0 6px rgba(212,25,138,0.3); }

/* ─── Sparklines ─────────────────────────────────────────── */
.sparkline {
  width: 60px;
  height: 24px;
  display: block;
  overflow: visible;
}

/* ─── Age Bar ────────────────────────────────────────────── */
.age-bar-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

.age-bar {
  height: 3px;
  width: 48px;
  background: var(--border);
  border-radius: 2px;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}

.age-bar::after {
  content: '';
  position: absolute;
  inset: 0;
  width: var(--age-pct);
  background: var(--age-color);
  border-radius: 2px;
  transition: width 0.3s ease;
}

.age-label {
  font-size: 0.6875rem;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  width: 24px;
  flex-shrink: 0;
}

/* ─── Proposals ──────────────────────────────────────────── */
.proposal-row {
  position: relative;
}

.proposal-row::after {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--row-val-pct);
  background: linear-gradient(to right, rgba(61,114,255,0.05), transparent);
  pointer-events: none;
  border-radius: 2px;
}

.amount-cell {
  font-weight: 700;
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
}

.days-out {
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
}

.days-overdue { color: var(--color-red); font-weight: 700; }

.days-arc {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: conic-gradient(
    var(--arc-color) calc(var(--arc-pct) * 1%),
    var(--border) 0
  );
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.5625rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
  position: relative;
}

.days-arc::before {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--bg);
}

.days-arc span {
  position: relative;
  z-index: 1;
}

/* ─── Calendar ───────────────────────────────────────────── */
.calendar-timeline-wrap {
  padding: 12px 24px 4px;
  border-bottom: 1px solid var(--border);
}

.timeline-axis {
  display: flex;
  justify-content: space-between;
  font-size: 0.5625rem;
  color: var(--text-muted);
  margin-bottom: 4px;
  padding: 0 2px;
  font-variant-numeric: tabular-nums;
}

.timeline-band {
  position: relative;
  height: 24px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.tl-event {
  position: absolute;
  top: 2px;
  bottom: 2px;
  border-radius: 3px;
  display: flex;
  align-items: center;
  padding: 0 4px;
  min-width: 4px;
  overflow: hidden;
}

.tl-event.tl-client   { background: rgba(61, 114, 255, 0.2); border-left: 2px solid var(--color-blue); }
.tl-event.tl-internal { background: rgba(107, 114, 128, 0.15); border-left: 2px solid #6B7280; }
.tl-event.tl-focus    { background: rgba(245, 158, 11, 0.12); border-left: 2px solid var(--color-warning); }

.tl-label {
  font-size: 0.5625rem;
  white-space: nowrap;
  overflow: hidden;
  color: var(--text-primary);
  opacity: 0.8;
}

.cal-loading {
  font-size: 0.8125rem;
  color: var(--text-muted);
  text-align: center;
  padding: 16px 0;
}

.calendar-day {
  margin-bottom: 16px;
}

.calendar-day:last-child {
  margin-bottom: 0;
}

.cal-day-label {
  display: block;
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.cal-events {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cal-event {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.83rem;
  padding: 5px 8px;
  border-radius: var(--radius-sm);
}

.cal-event.event-client   { border-left: 2px solid var(--color-blue); }
.cal-event.event-internal { border-left: 2px solid #6B7280; }

.cal-event:hover {
  background: var(--bg-hover);
}

.cal-time {
  font-size: 0.72rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  min-width: 56px;
  flex-shrink: 0;
}

.cal-title {
  color: var(--text-primary);
  flex: 1;
}

.cal-badge {
  font-size: 0.5625rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 4px;
  flex-shrink: 0;
}

.badge-client   { background: rgba(61,114,255,0.12); color: #7AA8FF; }
.badge-internal { background: rgba(107,114,128,0.12); color: #9CA3AF; }

/* ─── Site Health ────────────────────────────────────────── */
.site-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.site-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.83rem;
  transition: background 0.1s ease;
}

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

.site-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.site-dot.dot-green { background: #22C55E; box-shadow: 0 0 6px rgba(34,197,94,0.3); }
.site-dot.dot-red   { background: var(--color-red); box-shadow: 0 0 6px rgba(212,25,138,0.3); }

.site-name {
  flex: 1;
  font-size: 0.875rem;
  color: var(--text-primary);
}

.site-health-data {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.site-last-checked {
  font-size: 0.6875rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* ─── Uptime Donut ───────────────────────────────────────── */
.uptime-donut {
  position: relative;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}

.donut-svg {
  width: 28px;
  height: 28px;
  transform: rotate(-90deg);
  display: block;
}

.donut-bg {
  fill: none;
  stroke: var(--border);
  stroke-width: 4;
}

.donut-fill {
  fill: none;
  stroke-width: 4;
  stroke-linecap: round;
  transition: stroke-dasharray 0.5s ease;
}

.donut-green  { stroke: #22C55E; }
.donut-yellow { stroke: var(--color-warning); }
.donut-red    { stroke: var(--color-red); }

.donut-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.45rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  pointer-events: none;
}

/* ─── SSL Bar ────────────────────────────────────────────── */
.ssl-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
}

.ssl-gauge {
  height: 3px;
  width: 40px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  flex-shrink: 0;
}

.ssl-gauge-fill {
  height: 100%;
  width: var(--ssl-pct);
  background: var(--ssl-color);
  border-radius: 2px;
  transition: width 0.3s ease;
}

.ssl-days {
  font-size: 0.625rem;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  width: 24px;
  flex-shrink: 0;
}

.ssl-critical {
  color: var(--color-red) !important;
  font-weight: 700;
}

/* ─── Inbox Signal ───────────────────────────────────────── */
.inbox-histogram {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 28px;
  padding: 0 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
}

.hist-bar {
  flex: 1;
  height: var(--bar-h);
  background: var(--border-strong);
  border-radius: 2px 2px 0 0;
  transition: height 0.4s ease;
}

.hist-bar.hist-bar-now {
  background: var(--color-blue);
  opacity: 0.7;
}

.inbox-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.inbox-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border-left: 2px solid transparent;
  transition: background 0.1s ease;
}

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

.inbox-item.inbox-unread {
  border-left-color: var(--color-blue);
  background: rgba(61,114,255,0.04);
}

.inbox-sender {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text-primary);
}

.inbox-preview {
  font-size: 0.78rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.inbox-time {
  font-size: 0.6875rem;
  color: var(--text-muted);
}

/* ─── Scrollbar ──────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ─── Responsive ─────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    width: 56px;
    min-width: 56px;
  }
  .sidebar-label,
  .nav-text,
  .toggle-label,
  .last-refresh {
    display: none;
  }
  .nav-item {
    justify-content: center;
    padding: 10px 8px;
  }
  .main-content {
    margin-left: 56px;
  }
  .actions-list {
    flex-direction: column;
  }
}
