/* ═══════════════════════════════════════════════════════════
   VIBRA FIRESTORE — Data Architecture Layer v1.0
   Cost monitor panel + data layer UI
   ═══════════════════════════════════════════════════════════ */

/* ── Cost Monitor Badge (floating, top-right) ──────────────── */
#vf-cost-badge {
  position: fixed;
  top: 60px;
  right: 12px;
  z-index: 350;
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(9,6,18,.92);
  border: 1px solid rgba(138,87,255,.25);
  border-radius: 20px;
  padding: 4px 10px 4px 6px;
  font-family: var(--mono, monospace);
  font-size: .55rem;
  letter-spacing: .06em;
  color: rgba(200,190,255,.7);
  cursor: pointer;
  transition: border-color .2s, opacity .2s;
  opacity: 0;
  pointer-events: none;
}
#vf-cost-badge.vf-badge-visible {
  opacity: 1;
  pointer-events: auto;
}
#vf-cost-badge .vf-badge-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #00e676;
  animation: vfPulse 2s infinite;
}
#vf-cost-badge.vf-warn .vf-badge-dot { background: #ffc400; }
#vf-cost-badge.vf-critical .vf-badge-dot { background: #ff5252; }
#vf-cost-badge.vf-warn { border-color: rgba(255,196,0,.4); color: #ffc400; }
#vf-cost-badge.vf-critical { border-color: rgba(255,82,82,.5); color: #ff5252; }

@keyframes vfPulse {
  0%,100% { opacity: 1; transform: scale(1); }
  50% { opacity: .5; transform: scale(.85); }
}

/* ── Data Architecture Panel ───────────────────────────────── */
#vf-panel {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(5,3,12,.96);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  font-family: var(--mono, monospace);
}
#vf-panel.vf-open { display: flex; flex-direction: column; }

.vf-panel-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px;
  background: rgba(9,6,18,.98);
  border-bottom: 1px solid rgba(138,87,255,.2);
}
.vf-panel-title {
  flex: 1;
  font-family: var(--sans, sans-serif);
  font-size: 1rem;
  font-weight: 800;
  color: #f0ebff;
  letter-spacing: -.02em;
}
.vf-panel-close {
  background: none;
  border: none;
  color: rgba(200,190,255,.5);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px 8px;
}

.vf-panel-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 600px;
  margin: 0 auto;
  width: 100%;
}

/* ── Section card ──────────────────────────────────────────── */
.vf-card {
  background: rgba(255,255,255,.03);
  border: 1px solid rgba(138,87,255,.15);
  border-radius: 14px;
  padding: 16px;
}
.vf-card-title {
  font-size: .6rem;
  font-weight: 700;
  letter-spacing: .12em;
  color: rgba(138,87,255,.8);
  text-transform: uppercase;
  margin-bottom: 12px;
}

/* ── Cost ring ─────────────────────────────────────────────── */
.vf-cost-ring-wrap {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 14px;
}
.vf-cost-svg { width: 80px; height: 80px; flex-shrink: 0; }
.vf-cost-ring-bg { fill: none; stroke: rgba(255,255,255,.06); stroke-width: 8; }
.vf-cost-ring-fill {
  fill: none;
  stroke-width: 8;
  stroke-linecap: round;
  stroke: #8a57ff;
  stroke-dasharray: 220;
  stroke-dashoffset: 220;
  transform: rotate(-90deg);
  transform-origin: center;
  transition: stroke-dashoffset .6s ease, stroke .4s;
}
.vf-cost-ring-text {
  font-family: var(--sans, sans-serif);
  font-size: 14px;
  font-weight: 800;
  fill: #f0ebff;
  text-anchor: middle;
  dominant-baseline: central;
}
.vf-cost-ring-sub {
  font-size: 8px;
  fill: rgba(200,190,255,.5);
  text-anchor: middle;
  dominant-baseline: central;
}
.vf-cost-stats { flex: 1; }
.vf-cost-stat {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
  border-bottom: 1px solid rgba(255,255,255,.04);
  font-size: .6rem;
  color: rgba(200,190,255,.7);
}
.vf-cost-stat:last-child { border-bottom: none; }
.vf-cost-stat strong { color: #f0ebff; }

/* ── Ops bar breakdown ─────────────────────────────────────── */
.vf-ops-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.vf-ops-label { font-size: .55rem; color: rgba(200,190,255,.6); width: 80px; flex-shrink: 0; }
.vf-ops-bar-wrap {
  flex: 1;
  height: 6px;
  background: rgba(255,255,255,.06);
  border-radius: 3px;
  overflow: hidden;
}
.vf-ops-bar { height: 100%; border-radius: 3px; transition: width .5s ease; }
.vf-ops-val { font-size: .55rem; color: rgba(200,190,255,.7); width: 50px; text-align: right; }

/* ── Collection map ────────────────────────────────────────── */
.vf-collections {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.vf-collection {
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 10px;
  padding: 10px 12px;
}
.vf-col-name {
  font-size: .62rem;
  font-weight: 700;
  color: #8a57ff;
  margin-bottom: 4px;
}
.vf-col-desc { font-size: .52rem; color: rgba(200,190,255,.5); line-height: 1.4; }
.vf-col-count { font-size: .6rem; color: rgba(200,190,255,.7); margin-top: 6px; }

/* ── Cache status ──────────────────────────────────────────── */
.vf-cache-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255,255,255,.05);
  font-size: .6rem;
}
.vf-cache-row:last-child { border-bottom: none; }
.vf-cache-key { color: rgba(200,190,255,.7); }
.vf-cache-val { color: #00e676; font-weight: 700; }
.vf-cache-val.stale { color: #ffc400; }

/* ── Batch queue ───────────────────────────────────────────── */
.vf-batch-status {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: rgba(0,230,118,.05);
  border: 1px solid rgba(0,230,118,.15);
  border-radius: 10px;
  font-size: .6rem;
  color: rgba(200,190,255,.8);
}
.vf-batch-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #00e676;
  flex-shrink: 0;
}
.vf-batch-dot.idle { background: rgba(200,190,255,.3); animation: none; }
.vf-batch-dot.flushing { background: #ffc400; animation: vfPulse .5s infinite; }

/* ── Action buttons ────────────────────────────────────────── */
.vf-btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.vf-btn {
  flex: 1;
  min-width: 120px;
  padding: 10px 12px;
  background: rgba(138,87,255,.12);
  border: 1px solid rgba(138,87,255,.3);
  border-radius: 10px;
  color: #8a57ff;
  font-family: var(--mono, monospace);
  font-size: .58rem;
  font-weight: 700;
  letter-spacing: .06em;
  cursor: pointer;
  text-align: center;
  text-transform: uppercase;
  transition: background .2s, transform .1s;
}
.vf-btn:active { transform: scale(.97); background: rgba(138,87,255,.2); }
.vf-btn.danger { border-color: rgba(255,82,82,.3); color: #ff5252; background: rgba(255,82,82,.06); }
.vf-btn.success { border-color: rgba(0,230,118,.3); color: #00e676; background: rgba(0,230,118,.06); }

/* ── Alert toast for cost limits ───────────────────────────── */
.vf-cost-alert {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  z-index: 600;
  background: rgba(255,82,82,.15);
  border: 1px solid rgba(255,82,82,.4);
  border-radius: 20px;
  padding: 10px 20px;
  font-family: var(--mono, monospace);
  font-size: .62rem;
  color: #ff5252;
  letter-spacing: .06em;
  white-space: nowrap;
  opacity: 0;
  transition: opacity .3s, transform .3s;
  pointer-events: none;
}
.vf-cost-alert.vf-alert-show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Performance indicators ────────────────────────────────── */
.vf-perf-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.vf-perf-item {
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.07);
  border-radius: 10px;
  padding: 10px;
  text-align: center;
}
.vf-perf-val {
  font-family: var(--sans, sans-serif);
  font-size: 1.1rem;
  font-weight: 800;
  color: #8a57ff;
  line-height: 1;
  margin-bottom: 4px;
}
.vf-perf-label { font-size: .5rem; color: rgba(200,190,255,.5); letter-spacing: .08em; text-transform: uppercase; }
