/* ────────────────────────────────────────────────────────
   components.css — reusable atoms
   ──────────────────────────────────────────────────────── */

/* ── Cards (theme-aware glass) ─────────────────────────── */
.card {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--blur-card)) var(--saturation);
  -webkit-backdrop-filter: blur(var(--blur-card)) var(--saturation);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
}
/* Stagger reveal only on fresh navigation — see app.js nav().
   Without scoping to .cards-revealing this fired on every rerender
   (Drive list refresh, polling tick, etc.) which was distracting. */
body.cards-revealing .card {
  animation: cardReveal var(--dur-slow) var(--ease-spring) backwards;
}

/* Liquid glass shine — only visible on dark themes */
.style-liquid .card::before,
.style-mix .card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--shine);
  pointer-events: none;
  opacity: 0.6;
  z-index: 0;
}
.card > * { position: relative; z-index: 1; }

.card.p-12 { padding: var(--sp-12); }
.card.p-14 { padding: var(--sp-14); }
.card.p-16 { padding: var(--sp-16); }
.card.p-18 { padding: var(--sp-18); }
.card.p-20 { padding: var(--sp-20); }

/* Stagger children reveals — same .cards-revealing scope as the
   animation declaration above, so delays only apply on fresh nav. */
body.cards-revealing .card:nth-child(1) { animation-delay: 0.05s; }
body.cards-revealing .card:nth-child(2) { animation-delay: 0.10s; }
body.cards-revealing .card:nth-child(3) { animation-delay: 0.15s; }
body.cards-revealing .card:nth-child(4) { animation-delay: 0.20s; }
body.cards-revealing .card:nth-child(5) { animation-delay: 0.25s; }
body.cards-revealing .card:nth-child(6) { animation-delay: 0.30s; }
body.cards-revealing .card:nth-child(7) { animation-delay: 0.35s; }

/* ── Hero card (the big one at top of Hub/Finance) ─────── */
.hero {
  background: var(--gradient-hero);
  border-radius: var(--r-card);
  padding: var(--sp-20);
  color: #fff;
  position: relative;
  overflow: hidden;
  box-shadow: 0 12px 48px rgba(var(--accent-primary-rgb), 0.30);
  isolation: isolate;
}
body.cards-revealing .hero {
  animation: cardReveal var(--dur-slow) var(--ease-spring) backwards;
}
.hero::after {
  content: "";
  position: absolute;
  top: -40%; right: -30%;
  width: 80%; height: 200%;
  background: radial-gradient(circle, rgba(255,255,255,0.18), transparent 60%);
  pointer-events: none;
}

.hero-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-8);
}
.hero-label {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-6);
  font-size: var(--text-tiny);
  font-weight: var(--fw-bold);
  letter-spacing: var(--ls-caps);
  text-transform: uppercase;
  opacity: 0.92;
}
.hero-dot {
  width: 6px; height: 6px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 0 8px #fff;
  animation: pulse 1.6s ease-in-out infinite;
}
.hero-big {
  font-family: var(--f-display);
  font-size: 48px;
  font-weight: var(--fw-bold);
  letter-spacing: -0.03em;
  line-height: 1;
  margin-top: var(--sp-12);
  font-variant-numeric: tabular-nums;
}
.hero-big .unit {
  font-size: 16px;
  font-weight: var(--fw-semibold);
  margin-left: var(--sp-6);
  opacity: 0.85;
}
.hero-caption {
  font-size: var(--text-caption);
  opacity: 0.85;
  margin-top: var(--sp-4);
}
.hero-spark { margin-top: var(--sp-12); height: 52px; }

/* ── Chips ──────────────────────────────────────────────── */
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-4);
  padding: 3px 10px;
  border-radius: 999px;
  font-size: var(--text-tiny);
  font-weight: var(--fw-semibold);
  background: rgba(255,255,255,0.18);
  color: #fff;
  letter-spacing: var(--ls-caps);
}
.chip.success { background: var(--success-bg); color: var(--success); }
.chip.warn    { background: var(--warning-bg); color: var(--warning); }
.chip.danger  { background: var(--danger-bg);  color: var(--danger);  }
.chip.info    { background: var(--info-bg);    color: var(--info);    }

/* ── Sparkline ──────────────────────────────────────────── */
.sparkline { width: 100%; display: block; }
.sparkline .area { fill-opacity: 0.4; }

/* ── Buttons ────────────────────────────────────────────── */
.icon-btn {
  width: 36px; height: 36px;
  border-radius: var(--r-button);
  display: grid;
  place-items: center;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  transition: transform var(--dur-fast) var(--ease-spring),
              background var(--dur-fast);
}
.icon-btn:hover { background: var(--glass-bg-hover); }
.icon-btn:active { transform: scale(0.93); }
.icon-btn.primary {
  background: var(--gradient-primary);
  color: #fff;
  border-color: transparent;
}
.icon-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-8);
  padding: var(--sp-12) var(--sp-18);
  border-radius: var(--r-button);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  font-weight: var(--fw-semibold);
  font-size: var(--text-body);
  transition: transform var(--dur-fast) var(--ease-spring),
              background var(--dur-fast);
}
.btn:active { transform: scale(0.97); }
.btn.primary {
  background: var(--gradient-primary);
  color: #fff;
  border-color: transparent;
}
.btn.danger {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: transparent;
}
.btn.ghost {
  background: transparent;
  border: 1px solid var(--glass-border);
}

/* ── Section labels ─────────────────────────────────────── */
.section-label {
  font-size: var(--text-tiny);
  font-weight: var(--fw-bold);
  letter-spacing: var(--ls-caps);
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin: var(--sp-20) var(--sp-4) var(--sp-12);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
/* Secondary tier: tighter, lower-contrast, smaller top margin.
   Use for sub-grouping inside a primary section (e.g. integration
   sub-categories under "Інтеграції"). */
.section-label--secondary {
  font-size: 10px;
  font-weight: var(--fw-semibold);
  letter-spacing: var(--ls-snug);
  text-transform: none;
  color: var(--text-quaternary, var(--text-tertiary));
  opacity: 0.7;
  margin: var(--sp-12) var(--sp-4) var(--sp-6);
}
.section-link {
  font-weight: var(--fw-semibold);
  color: var(--accent-primary);
  text-transform: none;
  letter-spacing: var(--ls-snug);
  font-size: var(--text-caption);
  cursor: pointer;
}
.section-link:hover { opacity: 0.8; }

/* ── Rows (list items) ──────────────────────────────────── */
.row {
  display: flex;
  align-items: center;
  gap: var(--sp-12);
  padding: var(--sp-12) var(--sp-16);
  border-bottom: 1px solid var(--glass-border);
  transition: background var(--dur-fast);
}
.row:last-child  { border-bottom: 0; }
.row:hover       { background: var(--glass-bg-hover); }
.row-ic {
  width: 36px; height: 36px;
  flex-shrink: 0;
  display: grid; place-items: center;
  border-radius: var(--r-small);
  background: var(--glass-bg-strong);
  color: var(--accent-primary);
}
.row-body { flex: 1; min-width: 0; }
.row-title {
  font-size: var(--text-body);
  font-weight: var(--fw-semibold);
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row-meta {
  font-size: var(--text-caption);
  color: var(--text-tertiary);
  margin-top: 2px;
}
.row-trail {
  font-size: var(--text-caption);
  color: var(--text-tertiary);
}
.row-caret {
  color: var(--text-muted);
}

/* ── Stat tile (CPU/RAM/etc) ────────────────────────────── */
.stat-tile {
  padding: var(--sp-14);
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}
.stat-ic {
  width: 28px; height: 28px;
  border-radius: var(--r-small);
  background: rgba(var(--accent-primary-rgb), 0.18);
  color: var(--accent-primary);
  display: grid; place-items: center;
  margin-bottom: var(--sp-2);
}
.stat-tile.v-purple .stat-ic {
  background: rgba(var(--accent-secondary-rgb), 0.18);
  color: var(--accent-secondary);
}
.stat-tile.v-cyan .stat-ic {
  background: rgba(var(--accent-tertiary-rgb), 0.18);
  color: var(--accent-tertiary);
}
.stat-tile.v-warn .stat-ic { background: var(--warning-bg); color: var(--warning); }
.stat-label {
  font-size: var(--text-tiny);
  font-weight: var(--fw-bold);
  letter-spacing: var(--ls-caps);
  color: var(--text-tertiary);
  text-transform: uppercase;
}
.stat-value {
  font-family: var(--f-display);
  font-size: 22px;
  font-weight: var(--fw-bold);
  letter-spacing: var(--ls-tight);
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}
.meter {
  margin-top: var(--sp-6);
  width: 100%;
  height: 4px;
  background: var(--glass-bg-strong);
  border-radius: 999px;
  overflow: hidden;
}
.meter-fill {
  height: 100%;
  background: var(--accent-primary);
  border-radius: 999px;
  transition: width var(--dur-slow) var(--ease-smooth);
}
.meter-fill.success { background: var(--success); }
.meter-fill.warn    { background: var(--warning); }
.meter-fill.crit    { background: var(--danger); }

/* ── Quick actions (Hub home) ──────────────────────────── */
.quick-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--sp-8);
}
.quick {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-input);
  padding: var(--sp-10) var(--sp-6);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-6);
  text-align: center;
  transition:
    transform var(--dur-fast) var(--ease-spring),
    box-shadow var(--dur-fast) var(--ease-spring);
  color: var(--text-primary);
  /* Soft elevation so tiles read as lifted, not flat */
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.04),
    0 8px 20px rgba(0, 0, 0, 0.06);
}
.quick:active {
  /* Compound press: scale + slight tilt + crushed shadow */
  transform: scale(0.94) rotate(-0.4deg);
  box-shadow:
    0 1px 1px rgba(0, 0, 0, 0.10),
    0 2px 4px rgba(0, 0, 0, 0.04);
}
.quick-ic {
  width: 36px; height: 36px;
  border-radius: var(--r-small);
  display: grid; place-items: center;
  background: rgba(var(--accent-primary-rgb), 0.18);
  color: var(--accent-primary);
}
.quick-ic.v-green  { background: var(--success-bg); color: var(--success); }
.quick-ic.v-cyan   { background: rgba(var(--accent-tertiary-rgb), 0.18); color: var(--accent-tertiary); }
.quick-ic.v-orange { background: var(--warning-bg); color: var(--warning); }
.quick-ic.v-purple { background: rgba(var(--accent-secondary-rgb), 0.18); color: var(--accent-secondary); }
.quick-label {
  font-size: var(--text-tiny);
  font-weight: var(--fw-semibold);
  color: var(--text-secondary);
  line-height: 1.2;
}

/* ── Grids ──────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-10); }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: var(--sp-8); }

/* ── Toast (top-center, transient) ──────────────────────── */
.toast {
  position: fixed;
  top: calc(var(--safe-top) + 12px);
  left: 50%;
  transform: translateX(-50%) translateY(-80px);
  background: var(--bg-elevated);
  color: var(--text-primary);
  padding: var(--sp-10) var(--sp-16);
  border-radius: 999px;
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-card);
  font-size: var(--text-body-sm);
  font-weight: var(--fw-semibold);
  z-index: 9999;
  opacity: 0;
  transition: transform var(--dur-slow) var(--ease-spring),
              opacity var(--dur-fast);
  pointer-events: none;
  white-space: nowrap;
}
.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ── Bottom navigation ──────────────────────────────────── */
.botnav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 50;
  padding: var(--sp-10) var(--sp-12) calc(var(--sp-10) + var(--safe-bottom));
  pointer-events: none;
}
.botnav-inner {
  pointer-events: auto;
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  justify-content: space-around;
  align-items: center;
  background: var(--glass-bg-strong);
  backdrop-filter: blur(var(--blur-nav)) var(--saturation);
  -webkit-backdrop-filter: blur(var(--blur-nav)) var(--saturation);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-pill);
  padding: var(--sp-6);
  box-shadow: var(--shadow-nav);
}
.botnav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: var(--sp-6) 0;
  border-radius: 999px;
  color: var(--text-tertiary);
  font-size: 10px;
  font-weight: var(--fw-semibold);
  transition: color var(--dur-fast), background var(--dur-fast);
}
.botnav-btn.active {
  color: var(--accent-primary);
  background: rgba(var(--accent-primary-rgb), 0.10);
}
.botnav-btn:active { transform: scale(0.92); }

/* AI button — center, raised */
.botnav-ai {
  width: 52px; height: 52px;
  margin-top: -22px;
  border-radius: 999px;
  background: var(--gradient-primary);
  color: #fff;
  display: grid;
  place-items: center;
  box-shadow: 0 8px 24px rgba(var(--accent-primary-rgb), 0.45);
  transition: transform var(--dur-fast) var(--ease-spring);
}
.botnav-ai:active { transform: scale(0.92); }

/* ── Screen header ──────────────────────────────────────── */
.sh {
  margin-bottom: var(--sp-16);
}
.sh-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-12);
}
.sh-greet {
  font-size: var(--text-caption);
  color: var(--text-tertiary);
  font-weight: var(--fw-semibold);
}
.sh-title {
  font-family: var(--f-display);
  font-size: var(--text-display);
  font-weight: var(--fw-bold);
  letter-spacing: var(--ls-tight);
  line-height: var(--lh-tight);
  color: var(--text-primary);
  margin-top: 2px;
}
.sh-subtitle {
  font-size: var(--text-caption);
  color: var(--text-tertiary);
  margin-top: var(--sp-6);
}
.sh-avatar {
  width: 40px; height: 40px;
  border-radius: 999px;
  background: var(--gradient-primary);
  color: #fff;
  font-family: var(--f-display);
  font-weight: var(--fw-bold);
  font-size: 16px;
  display: grid;
  place-items: center;
  box-shadow: 0 4px 12px rgba(var(--accent-primary-rgb), 0.30);
}

/* ── Segmented control ──────────────────────────────────── */
.seg {
  display: inline-flex;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-button);
  padding: 3px;
  position: relative;
}
.seg-btn {
  position: relative;
  z-index: 1;
  padding: 6px 14px;
  font-size: var(--text-caption);
  font-weight: var(--fw-semibold);
  color: var(--text-tertiary);
  border-radius: var(--r-button);
  transition: color var(--dur-fast);
}
.seg-btn.active { color: var(--text-primary); }
.seg-indicator {
  position: absolute;
  top: 3px; bottom: 3px;
  background: var(--bg-elevated);
  border-radius: var(--r-button);
  box-shadow: 0 2px 8px rgba(0,0,0,0.10);
  transition: transform var(--dur-normal) var(--ease-spring),
              width var(--dur-normal) var(--ease-spring);
  z-index: 0;
}
