/* ============================================================
   VIBRA OBSERVABILITY — Stability Sprint PR #51
   Error tracking · Analytics · Cost monitor · Web Vitals
   Retention · Listener guard · Dev Dashboard
   ============================================================ */

/* ── Panel container ── */
#vo-panel {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: #06040f;
  overflow: hidden;
  flex-direction: column;
  font-family: 'DM Mono', monospace;
}
#vo-panel.vo-open {
  display: flex;
}

/* ── Header ── */
.vo-header {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .9rem 1rem;
  background: rgba(10,7,22,.95);
  border-bottom: 1px solid rgba(138,87,255,.2);
  flex-shrink: 0;
}
.vo-header-icon {
  font-size: 1.3rem;
}
.vo-header-title {
  font-size: .85rem;
  font-weight: 700;
  color: #e0d8ff;
  letter-spacing: .08em;
  flex: 1;
}
.vo-header-status {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-size: .6rem;
  color: rgba(160,140,220,.7);
  letter-spacing: .06em;
}
.vo-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #00e676;
  animation: vo-pulse 2s infinite;
}
.vo-status-dot.error { background: #ff5252; }
.vo-status-dot.warn  { background: #ffc400; }
@keyframes vo-pulse {
  0%,100% { opacity:1; }
  50%      { opacity:.4; }
}
.vo-close-btn {
  background: none;
  border: none;
  color: rgba(200,180,255,.6);
  font-size: 1.2rem;
  cursor: pointer;
  padding: .25rem .5rem;
  line-height: 1;
}

/* ── Tabs ── */
.vo-tabs {
  display: flex;
  gap: 0;
  background: rgba(10,7,22,.7);
  border-bottom: 1px solid rgba(138,87,255,.15);
  overflow-x: auto;
  flex-shrink: 0;
}
.vo-tabs::-webkit-scrollbar { display: none; }
.vo-tab {
  background: none;
  border: none;
  color: rgba(160,140,220,.55);
  font-family: 'DM Mono', monospace;
  font-size: .6rem;
  letter-spacing: .07em;
  padding: .65rem .9rem;
  cursor: pointer;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  transition: all .2s;
}
.vo-tab.active {
  color: #c8b8ff;
  border-bottom-color: #8a57ff;
}
.vo-tab .vo-tab-badge {
  display: inline-block;
  background: #ff5252;
  color: #fff;
  font-size: .5rem;
  padding: 0 .35rem;
  border-radius: 8px;
  margin-left: .3rem;
  vertical-align: middle;
}

/* ── Body ── */
.vo-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
}
.vo-body::-webkit-scrollbar { width: 4px; }
.vo-body::-webkit-scrollbar-thumb { background: rgba(138,87,255,.3); border-radius: 2px; }

/* ── Section cards ── */
.vo-section {
  margin-bottom: 1.2rem;
}
.vo-section-label {
  font-size: .58rem;
  letter-spacing: .1em;
  color: rgba(138,87,255,.8);
  margin-bottom: .5rem;
  text-transform: uppercase;
}

/* ── KPI Grid ── */
.vo-kpi-grid {
  display: grid;
  grid-template-columns: repeat(2,1fr);
  gap: .75rem;
  margin-bottom: 1rem;
}
.vo-kpi-card {
  background: rgba(138,87,255,.07);
  border: 1px solid rgba(138,87,255,.15);
  border-radius: 12px;
  padding: .85rem .9rem;
  position: relative;
  overflow: hidden;
}
.vo-kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--vo-color, #8a57ff);
  opacity: .7;
}
.vo-kpi-val {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--vo-color, #c8b8ff);
  line-height: 1;
  margin-bottom: .2rem;
}
.vo-kpi-label {
  font-size: .58rem;
  color: rgba(160,140,220,.6);
  letter-spacing: .06em;
}
.vo-kpi-delta {
  font-size: .55rem;
  margin-top: .3rem;
}
.vo-kpi-delta.up   { color: #00e676; }
.vo-kpi-delta.down { color: #ff5252; }

/* ── Event stream ── */
.vo-stream {
  background: rgba(6,4,15,.8);
  border: 1px solid rgba(138,87,255,.12);
  border-radius: 10px;
  padding: .75rem;
  max-height: 280px;
  overflow-y: auto;
  font-size: .62rem;
}
.vo-stream::-webkit-scrollbar { width: 3px; }
.vo-stream::-webkit-scrollbar-thumb { background: rgba(138,87,255,.3); border-radius: 2px; }
.vo-event-row {
  display: flex;
  gap: .6rem;
  align-items: flex-start;
  padding: .35rem 0;
  border-bottom: 1px solid rgba(138,87,255,.07);
  animation: vo-row-in .25s ease;
}
@keyframes vo-row-in {
  from { opacity:0; transform:translateX(-8px); }
  to   { opacity:1; transform:none; }
}
.vo-event-row:last-child { border-bottom: none; }
.vo-event-time {
  color: rgba(138,87,255,.5);
  white-space: nowrap;
  flex-shrink: 0;
  width: 70px;
}
.vo-event-type {
  white-space: nowrap;
  flex-shrink: 0;
  width: 100px;
  font-weight: 600;
}
.vo-event-type.error { color: #ff5252; }
.vo-event-type.warn  { color: #ffc400; }
.vo-event-type.info  { color: #00d4ff; }
.vo-event-type.track { color: #00e676; }
.vo-event-type.perf  { color: #b088ff; }
.vo-event-msg {
  color: rgba(220,210,255,.75);
  flex: 1;
  word-break: break-word;
}

/* ── Vitals ── */
.vo-vitals-grid {
  display: grid;
  grid-template-columns: repeat(3,1fr);
  gap: .6rem;
}
.vo-vital-card {
  background: rgba(6,4,15,.7);
  border: 1px solid rgba(138,87,255,.12);
  border-radius: 10px;
  padding: .7rem;
  text-align: center;
}
.vo-vital-val {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: .15rem;
}
.vo-vital-val.good  { color: #00e676; }
.vo-vital-val.ok    { color: #ffc400; }
.vo-vital-val.bad   { color: #ff5252; }
.vo-vital-label {
  font-size: .56rem;
  color: rgba(160,140,220,.55);
  letter-spacing: .06em;
}
.vo-vital-desc {
  font-size: .52rem;
  color: rgba(138,87,255,.6);
  margin-top: .2rem;
}

/* ── Cost tracker ── */
.vo-cost-bar-wrap {
  background: rgba(6,4,15,.7);
  border: 1px solid rgba(138,87,255,.12);
  border-radius: 10px;
  padding: .85rem;
  margin-bottom: .75rem;
}
.vo-cost-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: .5rem;
  font-size: .65rem;
}
.vo-cost-label { color: rgba(200,180,255,.7); }
.vo-cost-val { color: #c8b8ff; font-weight: 600; }
.vo-cost-bar-bg {
  height: 6px;
  background: rgba(138,87,255,.1);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: .75rem;
}
.vo-cost-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width .5s ease;
}
.vo-cost-bar-fill.reads  { background: #00d4ff; }
.vo-cost-bar-fill.writes { background: #b088ff; }
.vo-cost-bar-fill.deletes{ background: #ff5252; }

/* ── Retention chart ── */
.vo-retention-grid {
  display: grid;
  grid-template-columns: repeat(4,1fr);
  gap: .6rem;
  margin-bottom: .75rem;
}
.vo-ret-card {
  background: rgba(6,4,15,.7);
  border: 1px solid rgba(138,87,255,.12);
  border-radius: 10px;
  padding: .7rem;
  text-align: center;
}
.vo-ret-val {
  font-size: 1.1rem;
  font-weight: 700;
  color: #c8b8ff;
  margin-bottom: .15rem;
}
.vo-ret-label {
  font-size: .56rem;
  color: rgba(160,140,220,.55);
  letter-spacing: .06em;
}
.vo-ret-target {
  font-size: .5rem;
  color: rgba(138,87,255,.5);
  margin-top: .2rem;
}

/* ── Listener guard ── */
.vo-listener-list {
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.vo-listener-row {
  background: rgba(6,4,15,.7);
  border: 1px solid rgba(138,87,255,.12);
  border-radius: 10px;
  padding: .7rem .85rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: .63rem;
}
.vo-listener-name { color: rgba(200,180,255,.8); }
.vo-listener-count {
  font-weight: 700;
  padding: .15rem .5rem;
  border-radius: 8px;
  font-size: .6rem;
}
.vo-listener-count.ok   { background: rgba(0,230,118,.1); color: #00e676; }
.vo-listener-count.warn { background: rgba(255,196,0,.1);  color: #ffc400; }
.vo-listener-count.bad  { background: rgba(255,82,82,.1);  color: #ff5252; }

/* ── Error list ── */
.vo-error-list {
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.vo-error-card {
  background: rgba(255,82,82,.05);
  border: 1px solid rgba(255,82,82,.2);
  border-radius: 10px;
  padding: .75rem .9rem;
  font-size: .62rem;
}
.vo-error-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: .35rem;
}
.vo-error-name { color: #ff7070; font-weight: 700; }
.vo-error-count {
  background: rgba(255,82,82,.15);
  color: #ff5252;
  padding: .1rem .4rem;
  border-radius: 8px;
  font-size: .55rem;
}
.vo-error-msg { color: rgba(220,210,255,.65); margin-bottom: .25rem; }
.vo-error-time { color: rgba(138,87,255,.5); font-size: .55rem; }

/* ── Clear / export buttons ── */
.vo-action-row {
  display: flex;
  gap: .6rem;
  margin-top: .5rem;
  flex-wrap: wrap;
}
.vo-btn {
  background: rgba(138,87,255,.12);
  border: 1px solid rgba(138,87,255,.25);
  border-radius: 10px;
  color: rgba(200,180,255,.8);
  font-family: 'DM Mono', monospace;
  font-size: .6rem;
  padding: .5rem .9rem;
  cursor: pointer;
  letter-spacing: .06em;
  transition: background .2s;
}
.vo-btn:hover { background: rgba(138,87,255,.22); }
.vo-btn.danger {
  border-color: rgba(255,82,82,.3);
  color: #ff7070;
}

/* ── Empty state ── */
.vo-empty {
  text-align: center;
  padding: 2rem 1rem;
  color: rgba(138,87,255,.4);
  font-size: .65rem;
  letter-spacing: .07em;
}

/* ── Floating alert badge ── */
#vo-alert-badge {
  display: none;
  position: fixed;
  top: 56px;
  right: 12px;
  background: #ff5252;
  color: #fff;
  font-family: 'DM Mono', monospace;
  font-size: .58rem;
  padding: .3rem .6rem;
  border-radius: 20px;
  z-index: 1990;
  cursor: pointer;
  animation: vo-badge-in .25s ease;
}
@keyframes vo-badge-in {
  from { opacity:0; transform:scale(.7); }
  to   { opacity:1; transform:scale(1); }
}
