/* MacFleek — application chrome & shared components */

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100vh; }

body {
  font-family: var(--font-display);
  background: var(--surface-0);
  color: var(--text-primary);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  /* overflow:hidden removed — page.css enables scroll */
}

/* Force dark theme as default — user can toggle */
:root[data-theme="dark"] {
  color-scheme: dark;
  --text-primary:   #fafafa;
  --text-secondary: #d4d4d8;
  --text-tertiary:  #71717a;
  --text-inverse:   #18181b;
  --surface-0: #0a0a0a;
  --surface-1: #18181b;
  --surface-2: #27272a;
  --surface-vibrant: rgba(20, 20, 20, 0.72);
  --surface-hover:   rgba(167, 139, 250, 0.10);
  --surface-selected: rgba(99, 102, 241, 0.24);
}
:root[data-theme="light"] {
  color-scheme: light;
  --text-primary:   #18181b;
  --text-secondary: #52525b;
  --text-tertiary:  #a1a1aa;
  --text-inverse:   #fafafa;
  --surface-0: #ffffff;
  --surface-1: #fafafa;
  --surface-2: #f4f4f5;
  --surface-vibrant: rgba(255, 255, 255, 0.72);
  --surface-hover:   rgba(99, 102, 241, 0.06);
  --surface-selected: rgba(99, 102, 241, 0.12);
}

/* === App shell === */
.app {
  display: grid;
  grid-template-columns: 280px 1fr;
  height: 100vh;
  width: 100vw;
}

/* === Brand sidebar === */
.brand-sidebar {
  position: relative;
  background: var(--surface-1);
  border-right: 1px solid var(--hairline);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.brand-sidebar::before {
  content: "";
  position: absolute; inset: 0;
  background:
    radial-gradient(60% 40% at 20% 0%, rgba(99,102,241,0.16) 0%, transparent 70%),
    radial-gradient(50% 30% at 100% 100%, rgba(167,139,250,0.10) 0%, transparent 70%);
  pointer-events: none;
}
.brand-sidebar > * { position: relative; z-index: 1; }

.brand-header {
  padding: 24px 20px 18px;
  display: flex;
  gap: 12px;
  align-items: center;
}
.brand-mark {
  width: 38px; height: 38px;
  border-radius: 10px;
  background:
    radial-gradient(circle at 30% 25%, #a78bfa 0%, #6366f1 45%, #1e1b4b 100%);
  display: grid; place-items: center;
  box-shadow:
    0 0 0 0.5px rgba(255,255,255,0.08) inset,
    0 8px 22px -10px rgba(99,102,241,0.6);
  color: #fff;
}
.brand-name {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.01em;
  line-height: 1.1;
}
.brand-sub {
  font-size: 11px;
  color: var(--text-tertiary);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-top: 2px;
}

.nav-section-label {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  padding: 14px 24px 6px;
}

.nav-list {
  display: flex;
  flex-direction: column;
  padding: 0 12px;
  gap: 2px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 13.5px;
  color: var(--text-secondary);
  cursor: pointer;
  border: none;
  background: transparent;
  text-align: left;
  width: 100%;
  font-family: inherit;
  transition: background 0.18s var(--ease-apple-fast), color 0.18s var(--ease-apple-fast);
}
.nav-item:hover { background: var(--surface-hover); color: var(--text-primary); }
.nav-item .icon { width: 16px; height: 16px; color: var(--text-tertiary); flex-shrink: 0; transition: color 0.18s; }
.nav-item:hover .icon { color: var(--brand-400); }
.nav-item.active {
  background: var(--surface-selected);
  color: var(--text-primary);
  font-weight: 500;
}
.nav-item.active .icon { color: var(--brand-400); }
.nav-item .badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--brand-600) 18%, transparent);
  color: var(--brand-300);
  letter-spacing: 0.02em;
}

.brand-footer {
  margin-top: auto;
  padding: 16px 20px;
  border-top: 1px solid var(--hairline);
  display: flex; align-items: center; gap: 10px;
}
.theme-toggle {
  display: inline-flex; align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}
.theme-toggle button {
  border: none; background: transparent; cursor: pointer;
  padding: 4px 10px; font-size: 11px; font-weight: 500;
  color: var(--text-tertiary);
  border-radius: 999px;
  display: inline-flex; align-items: center; gap: 5px;
  transition: all 0.2s var(--ease-apple-fast);
  font-family: inherit;
}
.theme-toggle button.active {
  background: var(--surface-0);
  color: var(--text-primary);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.theme-toggle button .icon { width: 12px; height: 12px; }

.footer-meta {
  font-size: 10.5px;
  color: var(--text-tertiary);
  margin-left: auto;
  font-feature-settings: "tnum" 1;
}

/* === Main scroll area === */
.view-stage {
  overflow: auto;
  background: var(--surface-0);
  position: relative;
}
.view-stage::-webkit-scrollbar { width: 10px; }
.view-stage::-webkit-scrollbar-track { background: transparent; }
.view-stage::-webkit-scrollbar-thumb { background: var(--hairline-strong); border-radius: 999px; border: 3px solid transparent; background-clip: padding-box; }

.view-header {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 18px 32px 14px;
  background: color-mix(in srgb, var(--surface-0) 80%, transparent);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--hairline);
  display: flex;
  align-items: baseline;
  gap: 14px;
}
.view-header h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.view-header .crumbs {
  font-size: 12px;
  color: var(--text-tertiary);
  font-family: var(--font-mono);
}
.view-header .desc {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-tertiary);
  max-width: 50%;
  text-align: right;
}

.view-body { padding: 0; }

/* === Shared utility classes === */
.icon { display: inline-block; vertical-align: middle; }
.tnum { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--font-mono); }

/* Squircle (G2 continuous corner approximation via SVG path) */
.squircle { position: relative; }
.squircle > .squircle-bg {
  position: absolute; inset: 0;
  border-radius: 22px;
}

/* Hairline */
.hairline-card {
  border: 1px solid var(--hairline);
  background: var(--surface-1);
  border-radius: 14px;
}

/* Buttons (Apple-style) */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--hairline);
  background: var(--surface-2);
  color: var(--text-primary);
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.18s var(--ease-apple-spring), background 0.18s, box-shadow 0.18s;
}
.btn:hover { background: var(--surface-hover); }
.btn:active { transform: scale(0.98); }
.btn-primary {
  background: linear-gradient(180deg, #7c7ff5 0%, #6366f1 50%, #4f46e5 100%);
  border-color: rgba(255,255,255,0.08);
  color: white;
  box-shadow:
    0 0 0 1px rgba(99,102,241,0.4),
    0 8px 24px -8px rgba(99,102,241,0.6),
    inset 0 1px 0 rgba(255,255,255,0.18);
}
.btn-primary:hover { background: linear-gradient(180deg, #8a8df7 0%, #6f72f3 50%, #5b58e8 100%); }
.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover { background: var(--surface-hover); color: var(--text-primary); }
.btn-lg { padding: 12px 20px; font-size: 14px; border-radius: 12px; }
.btn-xl { padding: 14px 24px; font-size: 15px; border-radius: 13px; font-weight: 600; }

/* Pro badge */
.pro-tag {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 5px;
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: #1a0d00;
  box-shadow: 0 0 0 1px rgba(245,158,11,0.4), 0 2px 8px -2px rgba(245,158,11,0.4);
}

/* Stat number rhythm */
.stat-big {
  font-feature-settings: "tnum" 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.stat-big .num { font-size: 64px; font-weight: 700; line-height: 1; }
.stat-big .unit { font-size: 22px; font-weight: 500; color: var(--text-secondary); margin-left: 6px; vertical-align: top; padding-top: 6px; display: inline-block; }
.stat-big .label { display: block; font-size: 11px; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.08em; margin-top: 6px; }

/* Window chrome (used in mockups) */
.macwin {
  position: relative;
  border-radius: 14px;
  background: var(--surface-1);
  overflow: hidden;
  border: 1px solid var(--hairline-strong);
  box-shadow:
    0 0 0 0.5px rgba(255,255,255,0.06) inset,
    0 80px 100px -40px rgba(0,0,0,0.6),
    0 30px 60px -20px rgba(99,102,241,0.18);
}
.macwin-titlebar {
  display: flex; align-items: center;
  padding: 12px 14px;
  gap: 8px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--surface-2) 100%, transparent), color-mix(in srgb, var(--surface-1) 100%, transparent));
  border-bottom: 1px solid var(--hairline);
  -webkit-app-region: drag;
}
.traffic-lights { display: flex; gap: 8px; }
.traffic-lights span {
  width: 12px; height: 12px; border-radius: 50%;
  display: inline-block;
  box-shadow: inset 0 0 0 0.5px rgba(0,0,0,0.35);
}
.traffic-lights .tl-close  { background: radial-gradient(circle at 40% 35%, #ff7e72 0%, #ec5f4f 60%, #c0392b 100%); }
.traffic-lights .tl-min    { background: radial-gradient(circle at 40% 35%, #ffd76e 0%, #f5b842 60%, #c08b22 100%); }
.traffic-lights .tl-max    { background: radial-gradient(circle at 40% 35%, #7be391 0%, #4dc55f 60%, #1c8a34 100%); }

.macwin-title {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
  margin: 0 auto;
  padding-right: 56px;
}

/* Sparkline / progress fills */
.fill-anim {
  width: 0%;
  animation: fillWidth var(--d-epic) var(--ease-apple-spring) forwards;
}
@keyframes fillWidth { to { width: var(--target, 50%); } }

/* Tooltip */
.tip {
  position: absolute;
  background: rgba(10,10,12,0.92);
  color: #fafafa;
  font-size: 11px;
  padding: 8px 10px;
  border-radius: 8px;
  pointer-events: none;
  box-shadow: 0 8px 24px -8px rgba(0,0,0,0.6);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.08);
  white-space: nowrap;
}

/* Section grid utilities used throughout */
.row { display: flex; gap: 16px; }
.col { display: flex; flex-direction: column; gap: 16px; }
.muted { color: var(--text-tertiary); }
.dim { color: var(--text-secondary); }
.cap { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-tertiary); }

/* Reusable card chrome */
.surface {
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: 14px;
  padding: 18px;
}
.surface-recessed {
  background: var(--surface-2);
  border-radius: 12px;
}

/* Glass / vibrancy */
.glass {
  background: color-mix(in srgb, var(--surface-1) 65%, transparent);
  backdrop-filter: blur(28px) saturate(180%);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  border: 1px solid color-mix(in srgb, currentColor 8%, transparent);
}

/* Focus rings */
:focus-visible {
  outline: 2px solid var(--brand-400);
  outline-offset: 2px;
  border-radius: 6px;
}
