/* ═══════════════════════════════════════════════════════════════════
   Mousely Dashboard — styles.css
   Brand tokens sourced from mouse.ly/design-system.css
   ═══════════════════════════════════════════════════════════════════ */

/* ── Design Tokens ─────────────────────────────────────────────── */
:root {
  /* Brand palette */
  --ink: #000000;
  --muted: #505b63;
  --muted-soft: #647079;
  --blue: #079ceb;
  --blue-deep: #0078d4;
  --blue-ink: #0064b0;
  --blue-wash: #eef8ff;
  --page-sky: #f5fbff;
  --page-sky-deep: #f2f9ff;
  --paper: #ffffff;
  --paper-shade: #f1f3f5;
  --surface: rgba(255, 255, 255, 0.86);
  --line: rgba(20, 19, 19, 0.12);
  --line-strong: rgba(20, 19, 19, 0.22);

  /* Semantic colors */
  --success: #16a34a;
  --success-wash: #f0fdf4;
  --warning: #d97706;
  --warning-wash: #fffbeb;
  --danger: #dc2626;
  --danger-wash: #fef2f2;

  /* Shadows */
  --shadow-card: 0 1px 3px rgba(18, 32, 43, 0.06), 0 4px 16px rgba(18, 32, 43, 0.04);
  --shadow-card-hover: 0 4px 20px rgba(18, 32, 43, 0.10), 0 8px 32px rgba(18, 32, 43, 0.06);
  --shadow-float: 0 18px 58px rgba(18, 32, 43, 0.11);

  /* Radii */
  --radius-sm: 8px;
  --radius-control: 12px;
  --radius-card: 18px;
  --radius-product: 24px;

  /* Layout */
  --content-wide: 1200px;
  --gutter: clamp(16px, 4vw, 32px);
  --header-height: 64px;

  /* Typography */
  --font: "Mousely Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --tracking-display: -0.025em;

  /* Motion */
  --ease: cubic-bezier(0.19, 1, 0.22, 1);
  --duration-fast: 160ms;
  --duration-standard: 240ms;
}


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

html {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--page-sky);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  min-height: 100vh;
}

img { display: block; max-width: 100%; }
a { color: var(--blue-ink); text-decoration: none; }
a:hover { color: var(--blue-deep); }


/* ── Buttons ───────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 28px;
  border: none;
  border-radius: var(--radius-control);
  font-family: var(--font);
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease);
  text-decoration: none;
}

.btn-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.btn--primary {
  background: var(--blue);
  color: #fff;
  box-shadow: 0 2px 8px rgba(7, 156, 235, 0.25);
}
.btn--primary:hover {
  background: var(--blue-deep);
  color: #fff;
  box-shadow: 0 4px 16px rgba(7, 156, 235, 0.35);
  transform: translateY(-1px);
}

.btn--secondary {
  background: var(--paper-shade);
  color: var(--ink);
  border: 1px solid var(--border-soft);
}
.btn--secondary:hover {
  background: var(--border-soft);
  color: var(--ink);
  transform: translateY(-1px);
}

.demo-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(7, 156, 235, 0.1);
  color: var(--blue-deep);
  border: 1px solid rgba(7, 156, 235, 0.25);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 9999px;
  letter-spacing: 0.02em;
}

.btn--ghost {
  background: transparent;
  color: var(--muted);
  padding: 8px;
  border-radius: var(--radius-sm);
}
.btn--ghost:hover {
  background: var(--paper-shade);
  color: var(--ink);
}
.btn--ghost svg {
  width: 20px;
  height: 20px;
}



/* ── Auth Gate ─────────────────────────────────────────────────── */
.auth-gate {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: var(--gutter);
}

.auth-panel {
  text-align: center;
  max-width: 400px;
  width: 100%;
}

.auth-brand { display: inline-block; margin-bottom: 40px; }
.auth-brand img { height: 36px; width: auto; }

.auth-title {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: var(--tracking-display);
  margin-bottom: 8px;
}

.auth-subtitle {
  color: var(--muted);
  font-size: 0.9375rem;
  margin-bottom: 32px;
}

.auth-gate .btn--primary {
  width: 100%;
  padding: 14px 28px;
  font-size: 1rem;
}

.auth-note {
  margin-top: 20px;
  font-size: 0.8125rem;
  color: var(--muted-soft);
}
.auth-note a { color: var(--blue-ink); }


/* ── Loading Screen ────────────────────────────────────────────── */
.loading-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  gap: 20px;
}

.loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--line);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.loading-text {
  color: var(--muted);
  font-size: 0.9375rem;
}


/* ── Dashboard Layout ──────────────────────────────────────────── */
.dashboard {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.dashboard-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
  padding: 0 var(--gutter);
  background: var(--surface);
  backdrop-filter: blur(16px) saturate(1.6);
  -webkit-backdrop-filter: blur(16px) saturate(1.6);
  border-bottom: 1px solid var(--line);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-brand img {
  height: 28px;
  width: auto;
}

.header-divider {
  width: 1px;
  height: 24px;
  background: var(--line-strong);
}

.header-title {
  font-size: 1rem;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: var(--tracking-display);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-meta {
  font-size: 0.8125rem;
  color: var(--muted-soft);
}

.dashboard-main {
  flex: 1;
  max-width: var(--content-wide);
  width: 100%;
  margin: 0 auto;
  padding: 32px var(--gutter) 64px;
}

.dashboard-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px var(--gutter);
  border-top: 1px solid var(--line);
  background: var(--paper);
}

.footer-brand img {
  height: 22px;
  width: auto;
  opacity: 0.5;
  transition: opacity var(--duration-fast);
}
.footer-brand:hover img { opacity: 0.8; }

.footer-copy {
  font-size: 0.75rem;
  color: var(--muted-soft);
}


/* ── Sections ──────────────────────────────────────────────────── */
.section {
  margin-bottom: 40px;
}

.section-title {
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: var(--tracking-display);
  margin-bottom: 16px;
  color: var(--ink);
}


/* ── Cards ─────────────────────────────────────────────────────── */
.card {
  background: var(--paper);
  border-radius: var(--radius-card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-card);
  transition: box-shadow var(--duration-standard) var(--ease),
              transform var(--duration-standard) var(--ease);
}

.card:hover {
  box-shadow: var(--shadow-card-hover);
}


/* KPI Cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.card--kpi {
  padding: 24px 28px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
  overflow: hidden;
}

.card--kpi::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--blue), var(--blue-deep));
  opacity: 0;
  transition: opacity var(--duration-standard) var(--ease);
}

.card--kpi:hover::before { opacity: 1; }

.kpi-label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.kpi-value {
  font-size: 2.25rem;
  font-weight: 600;
  letter-spacing: var(--tracking-display);
  line-height: 1.1;
  color: var(--ink);
}


/* Metric Cards */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}

.card--metric {
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.metric-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--blue-ink);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.metric-value {
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: var(--tracking-display);
  line-height: 1.2;
}


/* Chart Cards */
.card--chart {
  padding: 24px;
}

.chart-title {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 16px;
}

.chart-container {
  position: relative;
  width: 100%;
  height: 280px;
}

.chart-container--donut {
  height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
}


/* Table Cards */
.card--table {
  padding: 24px;
}

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}


/* ── Grids ─────────────────────────────────────────────────────── */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}


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

.data-table th {
  text-align: left;
  font-weight: 500;
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 10px 14px;
  border-bottom: 2px solid var(--line);
  white-space: nowrap;
}

.data-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  white-space: nowrap;
}

.data-table tbody tr {
  transition: background var(--duration-fast);
}

.data-table tbody tr:hover {
  background: var(--page-sky);
}

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

/* Numeric alignment */
.data-table td:nth-child(n+2) {
  font-variant-numeric: tabular-nums;
}


/* Retention heatmap cells */
.data-table--retention td[data-retention] {
  text-align: center;
  font-weight: 500;
  border-radius: 4px;
}


/* ── Empty States ──────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  gap: 12px;
  text-align: center;
}

.empty-icon {
  width: 48px;
  height: 48px;
  color: var(--muted-soft);
}

.empty-state p {
  color: var(--muted-soft);
  font-size: 0.875rem;
}


/* ── Skeleton Loading ──────────────────────────────────────────── */
@keyframes shimmer {
  0% { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}

.skeleton {
  background: linear-gradient(90deg, var(--paper-shade) 25%, #e8eaed 37%, var(--paper-shade) 63%);
  background-size: 800px 100%;
  animation: shimmer 1.6s ease infinite;
  border-radius: var(--radius-sm);
}

.skeleton--text {
  height: 14px;
  width: 60%;
  margin-bottom: 8px;
}

.skeleton--value {
  height: 36px;
  width: 40%;
}


/* ── Refresh Animation ─────────────────────────────────────────── */
#refresh-btn.is-spinning svg {
  animation: spin 0.6s linear infinite;
}


/* ── Badge ─────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge--danger {
  background: var(--danger-wash);
  color: var(--danger);
}

.badge--warning {
  background: var(--warning-wash);
  color: var(--warning);
}

.badge--success {
  background: var(--success-wash);
  color: var(--success);
}


/* ── Responsive ────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .metric-grid { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr; }

  .dashboard-header {
    height: auto;
    flex-direction: column;
    padding: 12px var(--gutter);
    gap: 8px;
  }

  .header-left { width: 100%; }
  .header-right { width: 100%; justify-content: space-between; }

  .kpi-value { font-size: 1.75rem; }

  .card--chart { padding: 16px; }
  .card--table { padding: 16px; }

  .chart-container { height: 220px; }
  .chart-container--donut { height: 180px; }

  .dashboard-footer {
    flex-direction: column;
    gap: 8px;
    text-align: center;
  }
}

@media (max-width: 480px) {
  .header-divider { display: none; }
  .header-title { font-size: 0.875rem; }
}


/* ── Dashboard Fade-in ─────────────────────────────────────────── */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.dashboard:not([hidden]) {
  animation: fadeInUp 0.5s var(--ease) both;
}

.section {
  opacity: 0;
  animation: fadeInUp 0.5s var(--ease) both;
}

.section:nth-child(1) { animation-delay: 0.05s; }
.section:nth-child(2) { animation-delay: 0.10s; }
.section:nth-child(3) { animation-delay: 0.15s; }
.section:nth-child(4) { animation-delay: 0.20s; }
.section:nth-child(5) { animation-delay: 0.25s; }
.section:nth-child(6) { animation-delay: 0.30s; }
.section:nth-child(7) { animation-delay: 0.35s; }
.section:nth-child(8) { animation-delay: 0.40s; }
