/**
 * KAIRO Peptide Intelligence UI Styles
 *
 * Styling for peptide intelligence components:
 * - Phase indicators (destabilizing, stabilizing, adapting, consolidating)
 * - Maturity score displays
 * - Recommendation cards with tier badges
 * - Governance dashboard widgets
 * - Override pressure gauges
 * - Effectiveness tracking
 *
 * Philosophy: "Peptides surface through earned readiness, not request.
 *              The system whispers; silence is a valid outcome."
 */

/* ═══════════════════════════════════════════════════════════════════════════════
   CSS VARIABLES
   ═══════════════════════════════════════════════════════════════════════════════ */

:root {
  /* Phase Colors */
  --phase-destabilizing: var(--red-500);
  --phase-stabilizing: var(--amber-500);
  --phase-adapting: var(--blue-500);
  --phase-consolidating: var(--green-500);

  /* Tier Colors */
  --tier-1: var(--green-500);  /* Green - Foundational */
  --tier-2: var(--blue-500);  /* Blue - Intermediate */
  --tier-3: var(--violet-500);  /* Purple - Advanced */
  --tier-4: var(--red-500);  /* Red - Specialist */

  /* Maturity Colors */
  --maturity-novice: var(--slate-400);
  --maturity-intermediate: var(--blue-400);
  --maturity-advanced: var(--violet-500);
  --maturity-proven: var(--green-500);

  /* OPI Colors */
  --opi-green: var(--green-500);
  --opi-yellow: var(--amber-500);
  --opi-red: var(--red-500);

  /* Accent Colors */
  --peptide-primary: var(--violet-500);    /* Purple primary */
  --peptide-secondary: var(--violet-400);  /* Light purple */
  --peptide-accent: var(--violet-300);     /* Very light purple */
}

/* ═══════════════════════════════════════════════════════════════════════════════
   PEPTIDE INTELLIGENCE PAGE
   ═══════════════════════════════════════════════════════════════════════════════ */

/* Tab content container - ensure no extra padding/margin */
#content-peptide-intelligence {
  overflow-y: auto !important;
  overflow-x: hidden;
  padding: 0 !important;
  margin: 0 !important;
}

#content-peptide-intelligence .peptide-intelligence-page {
  min-height: 100%;
  background: linear-gradient(135deg, var(--slate-900) 0%, #1e1b2e 50%, var(--slate-900) 100%);
}

.peptide-intel-header {
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(12px);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   PHASE INDICATOR
   ═══════════════════════════════════════════════════════════════════════════════ */

.phase-indicator {
  border-radius: 12px;
  backdrop-filter: blur(8px);
  transition: all 0.3s ease;
}

.phase-badge {
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.75rem;
  font-weight: 700;
}

.phase-destabilizing {
  border-color: var(--phase-destabilizing);
  background: rgba(239, 68, 68, 0.1);
}

.phase-stabilizing {
  border-color: var(--phase-stabilizing);
  background: rgba(245, 158, 11, 0.1);
}

.phase-adapting {
  border-color: var(--phase-adapting);
  background: rgba(59, 130, 246, 0.1);
}

.phase-consolidating {
  border-color: var(--phase-consolidating);
  background: rgba(16, 185, 129, 0.1);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   MATURITY SCORE
   ═══════════════════════════════════════════════════════════════════════════════ */

.maturity-score {
  background: rgba(30, 41, 59, 0.8);
  border-radius: 16px;
  padding: 1.5rem;
  border: 1px solid rgba(139, 92, 246, 0.2);
}

.maturity-score-value {
  font-size: 3rem;
  font-weight: 800;
  line-height: 1;
}

.maturity-bar {
  height: 8px;
  background: rgba(51, 65, 85, 0.5);
  border-radius: 4px;
  overflow: hidden;
}

.maturity-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.5s ease-out;
}

.maturity-novice .maturity-bar-fill { background: var(--maturity-novice); }
.maturity-intermediate .maturity-bar-fill { background: var(--maturity-intermediate); }
.maturity-advanced .maturity-bar-fill { background: var(--maturity-advanced); }
.maturity-proven .maturity-bar-fill { background: var(--maturity-proven); }

/* ═══════════════════════════════════════════════════════════════════════════════
   PEPTIDE CARDS
   ═══════════════════════════════════════════════════════════════════════════════ */

.peptide-card {
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid rgba(139, 92, 246, 0.2);
  border-radius: 12px;
  padding: 1rem;
  transition: all 0.2s ease;
  backdrop-filter: blur(8px);
}

.peptide-card:hover {
  transform: translateY(-2px);
  border-color: rgba(139, 92, 246, 0.4);
  box-shadow: 0 8px 24px rgba(139, 92, 246, 0.15);
}

/* Tier-specific styling */
.peptide-card--tier-1 {
  border-left: 4px solid var(--tier-1);
}

.peptide-card--tier-2 {
  border-left: 4px solid var(--tier-2);
}

.peptide-card--tier-3 {
  border-left: 4px solid var(--tier-3);
}

.peptide-card--tier-4 {
  border-left: 4px solid var(--tier-4);
}

/* Recommendation states */
.peptide-card--surfaced {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.15), rgba(88, 28, 135, 0.1));
  border-color: rgba(139, 92, 246, 0.3);
}

.peptide-card--suppressed {
  background: rgba(30, 41, 59, 0.4);
  border-color: rgba(71, 85, 105, 0.3);
  opacity: 0.7;
}

.peptide-card--suppressed .peptide-name {
  color: var(--slate-400);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   TIER BADGES
   ═══════════════════════════════════════════════════════════════════════════════ */

.tier-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.tier-badge--1 {
  background: rgba(16, 185, 129, 0.2);
  color: #6ee7b7;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.tier-badge--2 {
  background: rgba(59, 130, 246, 0.2);
  color: #93c5fd;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.tier-badge--3 {
  background: rgba(139, 92, 246, 0.2);
  color: var(--violet-300);
  border: 1px solid rgba(139, 92, 246, 0.3);
}

.tier-badge--4 {
  background: rgba(239, 68, 68, 0.2);
  color: var(--red-300);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   CONFIDENCE INDICATORS
   ═══════════════════════════════════════════════════════════════════════════════ */

.confidence-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.confidence-bar {
  width: 60px;
  height: 6px;
  background: rgba(51, 65, 85, 0.5);
  border-radius: 3px;
  overflow: hidden;
}

.confidence-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s ease;
}

.confidence-high .confidence-bar-fill { background: var(--tier-1); }
.confidence-medium .confidence-bar-fill { background: var(--tier-2); }
.confidence-low .confidence-bar-fill { background: var(--slate-400); }

/* ═══════════════════════════════════════════════════════════════════════════════
   GOVERNANCE DASHBOARD
   ═══════════════════════════════════════════════════════════════════════════════ */

.governance-dashboard {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
}

.governance-widget {
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid rgba(139, 92, 246, 0.2);
  border-radius: 16px;
  padding: 1.5rem;
  transition: all 0.2s ease;
}

.governance-widget:hover {
  border-color: rgba(139, 92, 246, 0.4);
}

.governance-widget-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--slate-400);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 1rem;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   OVERRIDE PRESSURE INDEX (OPI) GAUGE
   ═══════════════════════════════════════════════════════════════════════════════ */

.opi-gauge {
  position: relative;
  width: 120px;
  height: 60px;
  margin: 0 auto;
}

.opi-gauge-arc {
  fill: none;
  stroke-width: 12;
  stroke-linecap: round;
}

.opi-gauge-bg {
  stroke: rgba(51, 65, 85, 0.5);
}

.opi-gauge-fill {
  transition: stroke-dashoffset 0.5s ease;
}

.opi-gauge--green .opi-gauge-fill { stroke: var(--opi-green); }
.opi-gauge--yellow .opi-gauge-fill { stroke: var(--opi-yellow); }
.opi-gauge--red .opi-gauge-fill { stroke: var(--opi-red); }

.opi-value {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  font-size: 1.5rem;
  font-weight: 700;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   DENSITY TREND CHART
   ═══════════════════════════════════════════════════════════════════════════════ */

.density-trend {
  height: 80px;
  display: flex;
  align-items: flex-end;
  gap: 4px;
  padding: 0.5rem 0;
}

.density-bar {
  flex: 1;
  min-width: 8px;
  background: rgba(139, 92, 246, 0.4);
  border-radius: 2px 2px 0 0;
  transition: all 0.3s ease;
}

.density-bar:hover {
  background: rgba(139, 92, 246, 0.8);
}

.density-bar--alert {
  background: rgba(239, 68, 68, 0.6);
}

.density-bar--alert:hover {
  background: rgba(239, 68, 68, 0.9);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   EFFECTIVENESS TRACKING
   ═══════════════════════════════════════════════════════════════════════════════ */

.effectiveness-card {
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid rgba(139, 92, 246, 0.2);
  border-radius: 12px;
  padding: 1rem;
}

.effectiveness-signal {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-weight: 600;
}

.effectiveness-signal--positive {
  background: rgba(16, 185, 129, 0.2);
  color: #6ee7b7;
}

.effectiveness-signal--neutral {
  background: rgba(148, 163, 184, 0.2);
  color: var(--slate-300);
}

.effectiveness-signal--negative {
  background: rgba(239, 68, 68, 0.2);
  color: var(--red-300);
}

.delta-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.875rem;
}

.delta-indicator--positive { color: #6ee7b7; }
.delta-indicator--negative { color: var(--red-300); }
.delta-indicator--neutral { color: var(--slate-400); }

/* ═══════════════════════════════════════════════════════════════════════════════
   SUPPRESSION REASONS
   ═══════════════════════════════════════════════════════════════════════════════ */

.suppression-reason {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: rgba(51, 65, 85, 0.3);
  border-radius: 8px;
  border-left: 3px solid var(--slate-500);
  font-size: 0.875rem;
  color: var(--slate-400);
}

.suppression-reason--phase {
  border-left-color: var(--phase-destabilizing);
}

.suppression-reason--tier {
  border-left-color: var(--tier-3);
}

.suppression-reason--confidence {
  border-left-color: var(--slate-500);
}

.suppression-reason--contraindication {
  border-left-color: var(--tier-4);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   SILENCE INDICATOR (Invariant 1)
   ═══════════════════════════════════════════════════════════════════════════════ */

.silence-indicator {
  text-align: center;
  padding: 3rem 2rem;
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.8), rgba(30, 27, 46, 0.8));
  border: 1px solid rgba(139, 92, 246, 0.2);
  border-radius: 16px;
}

.silence-indicator-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 1.5rem;
  background: rgba(139, 92, 246, 0.1);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  border: 2px solid rgba(139, 92, 246, 0.3);
}

.silence-indicator-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--slate-200);
  margin-bottom: 0.5rem;
}

.silence-indicator-message {
  color: var(--slate-400);
  max-width: 400px;
  margin: 0 auto;
  line-height: 1.6;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   TAB NAVIGATION
   ═══════════════════════════════════════════════════════════════════════════════ */

.peptide-tabs {
  display: flex;
  border-bottom: 1px solid rgba(139, 92, 246, 0.2);
  margin-bottom: 1.5rem;
}

.peptide-tab {
  flex: 1;
  padding: 1rem 1.5rem;
  text-align: center;
  font-weight: 500;
  color: var(--slate-400);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
}

.peptide-tab:hover {
  color: var(--slate-200);
  background: rgba(139, 92, 246, 0.05);
}

.peptide-tab--active {
  color: var(--violet-300);
  border-bottom-color: var(--violet-500);
  background: rgba(139, 92, 246, 0.1);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   RECOMMENDATION GRID
   ═══════════════════════════════════════════════════════════════════════════════ */

.recommendation-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
}

.recommendation-section {
  margin-bottom: 2rem;
}

.recommendation-section-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--slate-200);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid rgba(139, 92, 246, 0.2);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   AUDIT LOG
   ═══════════════════════════════════════════════════════════════════════════════ */

.audit-log {
  max-height: 400px;
  overflow-y: auto;
}

.audit-entry {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 0.75rem;
  border-bottom: 1px solid rgba(51, 65, 85, 0.5);
  transition: background 0.2s ease;
}

.audit-entry:hover {
  background: rgba(139, 92, 246, 0.05);
}

.audit-entry-time {
  font-size: 0.75rem;
  color: var(--slate-500);
  white-space: nowrap;
}

.audit-entry-type {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.125rem 0.5rem;
  border-radius: 4px;
  text-transform: uppercase;
}

.audit-entry-type--recommendation { background: rgba(139, 92, 246, 0.2); color: var(--violet-300); }
.audit-entry-type--override { background: rgba(245, 158, 11, 0.2); color: #fcd34d; }
.audit-entry-type--suppression { background: rgba(71, 85, 105, 0.4); color: var(--slate-400); }
.audit-entry-type--effectiveness { background: rgba(16, 185, 129, 0.2); color: #6ee7b7; }

/* ═══════════════════════════════════════════════════════════════════════════════
   SCROLLBAR STYLING
   ═══════════════════════════════════════════════════════════════════════════════ */

.peptide-intelligence-page ::-webkit-scrollbar {
  width: 8px;
}

.peptide-intelligence-page ::-webkit-scrollbar-track {
  background: rgba(30, 41, 59, 0.5);
  border-radius: 4px;
}

.peptide-intelligence-page ::-webkit-scrollbar-thumb {
  background: rgba(139, 92, 246, 0.3);
  border-radius: 4px;
}

.peptide-intelligence-page ::-webkit-scrollbar-thumb:hover {
  background: rgba(139, 92, 246, 0.5);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   LOADING STATES
   ═══════════════════════════════════════════════════════════════════════════════ */

.peptide-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem;
}

.peptide-loading-spinner {
  width: 48px;
  height: 48px;
  border: 3px solid rgba(139, 92, 246, 0.2);
  border-top-color: var(--violet-500);
  border-radius: 50%;
  animation: peptide-spin 1s linear infinite;
}

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

/* ═══════════════════════════════════════════════════════════════════════════════
   RESPONSIVE ADJUSTMENTS
   ═══════════════════════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
  .governance-dashboard {
    grid-template-columns: 1fr;
  }

  .recommendation-grid {
    grid-template-columns: 1fr;
  }

  .peptide-tabs {
    flex-wrap: wrap;
  }

  .peptide-tab {
    flex: 1 1 50%;
  }
}
