/* ═══════════════════════════════════════════════════════════════
   SAIHM — Sovereign AI Horizontal Memory — Web Portal
   Rev 63.13 | Powered by COTI | Apache 2.0
   ═══════════════════════════════════════════════════════════════ */

:root {
  --primary: #060e1a;
  --primary-light: #0d1a2e;
  --primary-mid: #111f36;
  --accent: #00d4aa;
  --accent-hover: #00f0c0;
  --accent-glow: rgba(0,212,170,0.25);
  --accent-dim: rgba(0,212,170,0.10);
  --accent-subtle: rgba(0,212,170,0.05);
  --text: #cdd6e0;
  --text-muted: #6b7f96;
  --text-bright: #f0f4f8;
  --surface: #0c1829;
  --surface-elevated: #132240;
  --surface-glass: rgba(12,24,41,0.70);
  --border: #1a2e4a;
  --border-light: #243a5c;
  --danger: #ff4466;
  --warning: #f5a623;
  --success: #00d4aa;
  --info: #4d8bff;
  --purple: #8b5cf6;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  --radius: 10px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.2);
  --shadow: 0 8px 32px rgba(0,0,0,0.35);
  --shadow-lg: 0 16px 48px rgba(0,0,0,0.4);
  --shadow-glow: 0 0 40px rgba(0,212,170,0.12);
  --transition: 0.25s cubic-bezier(0.4,0,0.2,1);
  --transition-slow: 0.5s cubic-bezier(0.4,0,0.2,1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; font-size: 16px; }

body {
  font-family: var(--font-sans);
  background: var(--primary);
  color: var(--text);
  line-height: 1.65;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Typography ── */
h1, h2, h3, h4 { color: var(--text-bright); font-weight: 700; line-height: 1.15; letter-spacing: -0.02em; }
h1 { font-size: 3.2rem; margin-bottom: 1.25rem; }
h2 { font-size: 2rem; margin-bottom: 0.75rem; }
h3 { font-size: 1.35rem; margin-bottom: 0.5rem; }
p { margin-bottom: 1rem; }
a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-hover); }
code { font-family: var(--font-mono); background: var(--surface); padding: 2px 8px; border-radius: 6px; font-size: 0.85em; border: 1px solid var(--border); }

/* ── Layout ── */
.container { max-width: 1240px; margin: 0 auto; padding: 0 2rem; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 1.5rem; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1.5rem; }
.grid-4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 1.25rem; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }

/* ── Navigation ── */
nav {
  position: sticky; top: 0; z-index: 100;
  background: rgba(6,14,26,0.88); backdrop-filter: blur(20px) saturate(1.4);
  border-bottom: 1px solid rgba(26,46,74,0.6);
  padding: 0.85rem 0;
}
nav .container { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 1rem; }
.nav-brand { font-size: 1.35rem; font-weight: 800; color: var(--accent); letter-spacing: 1px; text-transform: uppercase; }
.nav-brand span { color: var(--text-muted); font-weight: 400; font-size: 0.75rem; margin-left: 0.75rem; letter-spacing: 0; text-transform: none; }
.nav-links { display: flex; gap: 1.75rem; flex-wrap: wrap; }
.nav-links a { color: var(--text-muted); font-size: 0.88rem; font-weight: 500; position: relative; padding-bottom: 2px; }
.nav-links a::after { content: ''; position: absolute; bottom: -2px; left: 0; width: 0; height: 2px; background: var(--accent); transition: width var(--transition); border-radius: 1px; }
.nav-links a:hover, .nav-links a.active { color: var(--accent); }
.nav-links a:hover::after, .nav-links a.active::after { width: 100%; }
#lang-select { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.35rem 0.6rem; font-size: 0.82rem; cursor: pointer; }

/* ── Hero ── */
.hero {
  padding: 6rem 0 5rem;
  text-align: center;
  background: linear-gradient(160deg, var(--primary) 0%, var(--primary-light) 40%, var(--primary-mid) 70%, var(--primary) 100%);
  position: relative; overflow: hidden;
}
.hero::before {
  content: ''; position: absolute; top: -60%; left: -30%;
  width: 160%; height: 200%;
  background: radial-gradient(ellipse at 50% 30%, rgba(0,212,170,0.07) 0%, transparent 55%);
  animation: heroPulse 10s ease-in-out infinite;
}
.hero::after {
  content: ''; position: absolute; bottom: -40%; right: -20%;
  width: 120%; height: 120%;
  background: radial-gradient(ellipse at 70% 80%, rgba(77,139,255,0.04) 0%, transparent 50%);
  animation: heroPulse 12s ease-in-out infinite reverse;
}
@keyframes heroPulse { 0%,100% { opacity: 0.4; transform: scale(1); } 50% { opacity: 1; transform: scale(1.03); } }
.hero h1 { font-size: 3.5rem; position: relative; max-width: 800px; margin: 0 auto 1rem; }
.hero h1 .accent { color: var(--accent); background: linear-gradient(135deg, var(--accent), #4d8bff); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.hero p { font-size: 1.15rem; color: var(--text-muted); max-width: 680px; margin: 0 auto 2.5rem; position: relative; line-height: 1.7; }
.hero-stats { display: flex; justify-content: center; gap: 3.5rem; flex-wrap: wrap; position: relative; }
.stat-box { text-align: center; }
.stat-box .value { font-size: 2.2rem; font-weight: 800; color: var(--accent); display: block; letter-spacing: -0.02em; }
.stat-box .label { font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-top: 0.25rem; }

/* ── Mainnet Banner ── */
.mainnet-banner {
  background: linear-gradient(90deg, rgba(0,212,170,0.08), rgba(77,139,255,0.08), rgba(0,212,170,0.08));
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 0;
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}
.mainnet-banner strong { color: var(--accent); font-weight: 600; }
.mainnet-banner .separator { margin: 0 1rem; color: var(--border-light); }

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
  position: relative;
}
.card:hover { transform: translateY(-3px); border-color: rgba(0,212,170,0.4); box-shadow: var(--shadow-glow); }
.card-header { display: flex; align-items: center; gap: 0.85rem; margin-bottom: 1rem; }
.card-icon {
  width: 44px; height: 44px; border-radius: 12px;
  background: linear-gradient(135deg, var(--accent-dim), rgba(77,139,255,0.1));
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; font-weight: 700; color: var(--accent);
  border: 1px solid rgba(0,212,170,0.15);
}
.card-title { font-size: 1.05rem; font-weight: 600; }
.card-desc { font-size: 0.88rem; color: var(--text-muted); line-height: 1.6; margin-bottom: 1rem; }

/* ── Doc Cards (audience-colored) ── */
.doc-card { position: relative; overflow: hidden; }
.doc-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--accent); border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.doc-card.audience-regulator::before { background: linear-gradient(90deg, #f5a623, #ff6b35); }
.doc-card.audience-developer::before { background: linear-gradient(90deg, #4d8bff, #8b5cf6); }
.doc-card.audience-agent::before { background: linear-gradient(90deg, var(--accent), #2fb4a8); }
.doc-card.audience-executive::before { background: linear-gradient(90deg, #8b5cf6, #ec4899); }
.doc-card.audience-all::before { background: linear-gradient(90deg, var(--accent), #4d8bff, #8b5cf6); }
.doc-audience-tag {
  display: inline-block; padding: 0.15rem 0.6rem; border-radius: 20px;
  font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;
  margin-bottom: 0.75rem;
}
.tag-regulator { background: rgba(245,166,35,0.15); color: #f5a623; }
.tag-developer { background: rgba(77,139,255,0.15); color: #4d8bff; }
.tag-agent { background: rgba(0,212,170,0.15); color: var(--accent); }
.tag-executive { background: rgba(139,92,246,0.15); color: #8b5cf6; }
.tag-all { background: rgba(0,212,170,0.1); color: var(--text-muted); }

/* ── KPI Dashboard ── */
.kpi-section { padding: 3.5rem 0; }
.kpi-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2rem; flex-wrap: wrap; gap: 1rem; }
.kpi-timestamp { font-size: 0.82rem; color: var(--text-muted); font-family: var(--font-mono); }
.data-source { font-size: 0.75rem; font-family: var(--font-mono); padding: 0.2rem 0.6rem; border-radius: 4px; display: inline-block; margin-top: 0.3rem; }
.data-source.live { color: var(--success); background: rgba(0, 212, 170, 0.1); border: 1px solid rgba(0, 212, 170, 0.3); }
.data-source.live::before { content: "● "; }
.data-source.simulated { color: var(--warning); background: rgba(255, 183, 77, 0.1); border: 1px solid rgba(255, 183, 77, 0.3); }
.data-source.simulated::before { content: "○ "; }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 2rem; }
.kpi-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.25rem; text-align: center;
  transition: border-color var(--transition);
}
.kpi-card:hover { border-color: var(--border-light); }
.kpi-value { font-size: 1.7rem; font-weight: 800; color: var(--accent); letter-spacing: -0.02em; }
.kpi-label { font-size: 0.78rem; color: var(--text-muted); margin-top: 0.3rem; text-transform: uppercase; letter-spacing: 0.3px; }

/* ── Charts ── */
.chart-container {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1.75rem;
  margin-bottom: 1.5rem; min-height: 250px; position: relative;
}
.chart-title { font-size: 0.95rem; font-weight: 600; margin-bottom: 1rem; color: var(--text-bright); }
.chart-bar-group { display: flex; align-items: flex-end; gap: 4px; height: 180px; padding-top: 1rem; }
.chart-bar {
  flex: 1; background: var(--accent); border-radius: 4px 4px 0 0;
  min-width: 8px; transition: height var(--transition-slow), opacity var(--transition);
  position: relative; opacity: 0.85;
}
.chart-bar:hover { opacity: 1; }
.chart-bar[data-provider="filecoin"] { background: #0090ff; }
.chart-bar[data-provider="storj"] { background: #2fb4a8; }
.chart-bar[data-provider="arweave"] { background: #ff6600; }
.chart-bar[data-provider="ipfs"] { background: #65c2cb; }
.chart-legend { display: flex; gap: 1.5rem; margin-top: 1rem; flex-wrap: wrap; }
.legend-item { display: flex; align-items: center; gap: 0.4rem; font-size: 0.78rem; color: var(--text-muted); }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; }

/* ── PHI Gauge ── */
.phi-gauge { text-align: center; padding: 1rem 0; }
.phi-ring { width: 160px; height: 160px; margin: 0 auto; position: relative; }
.phi-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.phi-ring circle { fill: none; stroke-width: 10; stroke-linecap: round; }
.phi-ring .bg { stroke: var(--border); }
.phi-ring .fg { stroke: var(--accent); transition: stroke-dashoffset 1.2s cubic-bezier(0.4,0,0.2,1); filter: drop-shadow(0 0 8px rgba(0,212,170,0.4)); }
.phi-score { position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); font-size: 2rem; font-weight: 800; color: var(--accent); }
.phi-label { margin-top: 0.5rem; font-size: 0.85rem; color: var(--text-muted); }

/* ── Compliance Query Tool ── */
.query-section { padding: 3.5rem 0; }
.query-box {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 2rem;
}
.query-tabs { display: flex; gap: 0.5rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.query-tab {
  padding: 0.5rem 1.1rem; border-radius: var(--radius);
  background: var(--primary); border: 1px solid var(--border);
  color: var(--text-muted); cursor: pointer; font-size: 0.83rem; font-weight: 500;
  transition: all var(--transition);
}
.query-tab.active, .query-tab:hover { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }
.query-input-group { display: flex; gap: 0.75rem; margin-bottom: 1rem; flex-wrap: wrap; }
.query-input {
  flex: 1; min-width: 200px;
  background: var(--primary); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 0.75rem 1rem;
  color: var(--text); font-family: var(--font-mono); font-size: 0.88rem;
  transition: border-color var(--transition);
}
.query-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0,212,170,0.1); }
.btn {
  padding: 0.75rem 1.5rem; border-radius: var(--radius);
  border: none; cursor: pointer; font-weight: 600;
  font-size: 0.88rem; transition: all var(--transition);
  letter-spacing: 0.3px;
}
.btn-primary { background: var(--accent); color: var(--primary); }
.btn-primary:hover { background: var(--accent-hover); box-shadow: 0 4px 16px rgba(0,212,170,0.3); transform: translateY(-1px); }
.btn-secondary { background: var(--surface-elevated); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-sm { padding: 0.5rem 1rem; font-size: 0.8rem; }
.query-result {
  background: var(--primary); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.25rem;
  font-family: var(--font-mono); font-size: 0.82rem;
  max-height: 400px; overflow-y: auto;
  white-space: pre-wrap; line-height: 1.6;
}

/* ── Chatbot ── */
.chatbot-toggle {
  position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 1000;
  width: 56px; height: 56px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #2fb4a8);
  color: var(--primary); border: none; cursor: pointer; font-size: 1.5rem;
  box-shadow: var(--shadow), 0 0 24px rgba(0,212,170,0.2);
  transition: transform var(--transition), box-shadow var(--transition);
}
.chatbot-toggle:hover { transform: scale(1.08); box-shadow: var(--shadow-lg), 0 0 32px rgba(0,212,170,0.3); }
.chatbot-panel {
  position: fixed; bottom: 5rem; right: 1.5rem; z-index: 999;
  width: 400px; max-height: 540px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-xl); box-shadow: var(--shadow-lg);
  display: none; flex-direction: column;
  backdrop-filter: blur(12px);
}
.chatbot-panel.open { display: flex; }
.chatbot-header { padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.chatbot-header h4 { font-size: 0.95rem; }
.chatbot-close { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 1.2rem; transition: color var(--transition); }
.chatbot-close:hover { color: var(--text-bright); }
.chatbot-messages { flex: 1; padding: 1rem; overflow-y: auto; display: flex; flex-direction: column; gap: 0.75rem; max-height: 350px; }
.chat-msg { max-width: 85%; padding: 0.75rem 1rem; border-radius: var(--radius-lg); font-size: 0.85rem; line-height: 1.5; }
.chat-msg.bot { background: var(--primary-light); align-self: flex-start; border: 1px solid var(--border); }
.chat-msg.user { background: var(--accent-dim); align-self: flex-end; border: 1px solid rgba(0,212,170,0.25); }
.chatbot-input-area { padding: 0.75rem; border-top: 1px solid var(--border); display: flex; gap: 0.5rem; }
.chatbot-input { flex: 1; background: var(--primary); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.6rem 0.75rem; color: var(--text); font-size: 0.85rem; }
.chatbot-input:focus { outline: none; border-color: var(--accent); }
.chatbot-send { width: 36px; height: 36px; border-radius: var(--radius); background: var(--accent); color: var(--primary); border: none; cursor: pointer; font-size: 1rem; }

/* ── Sections ── */
section { padding: 4rem 0; }
section + section { border-top: 1px solid rgba(26,46,74,0.5); }
.section-header { text-align: center; margin-bottom: 3rem; }
.section-header h2 { margin-bottom: 0.5rem; }
.section-header p { color: var(--text-muted); max-width: 620px; margin: 0 auto; font-size: 1.05rem; }
.section-eyebrow { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 2px; color: var(--accent); font-weight: 600; margin-bottom: 0.75rem; display: block; }

/* ── Footer ── */
footer {
  background: var(--surface); border-top: 1px solid var(--border);
  padding: 3rem 0 2rem; text-align: center; font-size: 0.85rem; color: var(--text-muted);
}
footer a { color: var(--accent); }
.footer-grid { display: flex; justify-content: center; gap: 3rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.footer-col { text-align: left; min-width: 140px; }
.footer-col h4 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 1px; color: var(--text-bright); margin-bottom: 0.75rem; font-weight: 600; }
.footer-col a { display: block; color: var(--text-muted); font-size: 0.82rem; margin-bottom: 0.4rem; }
.footer-col a:hover { color: var(--accent); }
.footer-bottom { padding-top: 1.5rem; border-top: 1px solid var(--border); }

/* ── Table ── */
table { width: 100%; border-collapse: collapse; margin: 1rem 0; }
th, td { padding: 0.65rem 0.85rem; text-align: left; border-bottom: 1px solid var(--border); font-size: 0.85rem; }
th { color: var(--accent); font-weight: 600; background: var(--primary); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.5px; }
tr:hover { background: var(--accent-subtle); }

/* ── Status Badges ── */
.badge { display: inline-block; padding: 0.2rem 0.65rem; border-radius: 20px; font-size: 0.72rem; font-weight: 600; letter-spacing: 0.3px; }
.badge-healthy { background: rgba(0,212,170,0.12); color: var(--success); }
.badge-warning { background: rgba(245,166,35,0.12); color: var(--warning); }
.badge-advisory { background: rgba(245,166,35,0.12); color: var(--warning); }
.badge-critical { background: rgba(255,68,102,0.12); color: var(--danger); }

/* ── Agent Dashboard ── */
.agent-lookup-bar { display: flex; gap: 0.75rem; max-width: 600px; margin: 0 auto; }
.agent-stat-row { display: flex; justify-content: space-between; padding: 0.55rem 0; border-bottom: 1px solid var(--border); font-size: 0.85rem; }
.agent-stat-row:last-child { border-bottom: none; }
.agent-stat-row span:last-child { font-family: var(--font-mono); color: var(--accent); font-weight: 500; }
.agent-prs-bar-track { width: 100%; height: 8px; background: var(--primary); border-radius: 4px; margin-top: 0.75rem; overflow: hidden; }
.agent-prs-bar-fill { height: 100%; border-radius: 4px; transition: width 0.8s ease, background 0.3s ease; }

/* ── Responsive ── */
@media (max-width: 768px) {
  .hero h1 { font-size: 2.2rem; }
  h1 { font-size: 2.2rem; }
  .hero-stats { gap: 1.5rem; }
  .chatbot-panel { width: calc(100vw - 2rem); right: 1rem; }
  .nav-links { gap: 0.85rem; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .container { padding: 0 1.25rem; }
  .footer-grid { gap: 2rem; }
  .mainnet-banner { font-size: 0.72rem; }
  .mainnet-banner .separator { margin: 0 0.5rem; }
}
@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .hero h1 { font-size: 1.8rem; }
  .hero-stats { gap: 1rem; }
  .stat-box .value { font-size: 1.6rem; }
}
