/* ================================================================
   Proof of Claw — Shared Stylesheet
   Common base styles, variables, and reusable components.
   ================================================================ */

/* ── Reset ── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

/* ── Design Tokens ── */
:root {
  --bg-primary: #06080d;
  --bg-secondary: #0c1018;
  --bg-card: #0f1520;
  --bg-card-hover: #141c2a;
  --cyan: #00e5ff;
  --cyan-dim: #00a3b5;
  --cyan-glow: rgba(0, 229, 255, 0.15);
  --amber: #ffb300;
  --amber-dim: #c68a00;
  --amber-glow: rgba(255, 179, 0, 0.12);
  --red: #ff3d5a;
  --green: #00e676;
  --green-glow: rgba(0, 230, 118, 0.12);
  --purple: #b388ff;
  --purple-glow: rgba(179, 136, 255, 0.15);
  --text-primary: #e8ecf4;
  --text-secondary: #8892a4;
  --text-dim: #4a5568;
  --border: rgba(255, 255, 255, 0.06);
  --border-cyan: rgba(0, 229, 255, 0.2);
  --font-display: 'Syne', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --sidebar-w: 240px;
  --sidebar-w-collapsed: 60px;
  --topbar-h: 60px;
}

/* ── Base ── */
html { scroll-behavior: smooth; }

body {
  font-family: var(--font-mono);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  font-size: 14px;
  overflow-x: hidden;
}

/* ── Scanline Overlay (GPU-promoted) ── */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(0,0,0,0.03) 2px, rgba(0,0,0,0.03) 4px);
  pointer-events: none;
  z-index: 9999;
  will-change: transform;
  transform: translateZ(0);
}

/* ── Grid Background ── */
.grid-bg,
body.has-grid::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(0, 229, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 229, 255, 0.03) 1px, transparent 1px);
  background-size: 60px 60px;
  pointer-events: none;
  z-index: 0;
}

/* ── Skip to Content (Accessibility) ── */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--cyan);
  color: var(--bg-primary);
  padding: 0.5rem 1rem;
  z-index: 100000;
  font-weight: 700;
  text-decoration: none;
  transition: top 0.2s;
}
.skip-link:focus {
  top: 0;
}

/* ── Visually Hidden (Screen Reader Only) ── */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* ================================================================
   APP SIDEBAR (agents, dashboard, messages, proofs)
   ================================================================ */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 200;
  transition: width 0.25s ease;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
}

.sidebar-logo .claw-icon {
  width: 32px;
  height: 32px;
  object-fit: contain;
  filter: drop-shadow(0 0 8px var(--cyan));
}

.sidebar-logo .logo-text {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1rem;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.sidebar-nav {
  flex: 1;
  padding: 1rem 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  list-style: none;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 1.5rem;
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  transition: all 0.2s;
  border-left: 3px solid transparent;
}

.sidebar-nav a:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.03);
}

.sidebar-nav a.active {
  color: var(--cyan);
  border-left-color: var(--cyan);
  background: rgba(0, 229, 255, 0.06);
}

.sidebar-nav a[aria-current="page"] {
  color: var(--cyan);
  border-left-color: var(--cyan);
  background: rgba(0, 229, 255, 0.06);
}

.sidebar-nav .nav-icon {
  font-size: 1rem;
  width: 1.25rem;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-bottom {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.sidebar-bottom .btn-new-agent {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  background: var(--cyan);
  color: var(--bg-primary);
  border: none;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s;
}

.sidebar-bottom .btn-new-agent:hover {
  background: var(--cyan-dim);
  box-shadow: 0 0 20px rgba(0, 229, 255, 0.25);
}

.sidebar-bottom .btn-home {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s;
}

.sidebar-bottom .btn-home:hover {
  color: var(--text-secondary);
  border-color: var(--border-cyan);
}

/* ── Sidebar Toggle ── */
.sidebar-toggle {
  position: absolute;
  top: 12px;
  right: -14px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  z-index: 201;
  transition: all 0.2s;
}

.sidebar-toggle:hover {
  color: var(--cyan);
  border-color: var(--border-cyan);
  background: var(--bg-card);
}

/* ── Sidebar Collapsed State ── */
body.sidebar-collapsed .sidebar { width: var(--sidebar-w-collapsed); }
body.sidebar-collapsed .sidebar .logo-text { display: none; }
body.sidebar-collapsed .sidebar-logo { justify-content: center; }
body.sidebar-collapsed .sidebar-nav a { justify-content: center; padding: 0.7rem 0; font-size: 0; gap: 0; }
body.sidebar-collapsed .sidebar-nav a .nav-icon { font-size: 1.1rem; width: auto; }
body.sidebar-collapsed .sidebar-bottom { padding: 0.75rem 0.5rem; }
body.sidebar-collapsed .sidebar-bottom .btn-new-agent { font-size: 0; padding: 0.6rem; letter-spacing: 0; }
body.sidebar-collapsed .sidebar-bottom .btn-new-agent::after { content: '+'; font-size: 1.2rem; font-weight: 700; letter-spacing: 0; }
body.sidebar-collapsed .sidebar-bottom .btn-home { display: none; }
body.sidebar-collapsed .sidebar-toggle { transform: rotate(180deg); }
body.sidebar-collapsed #poc-connection-slot { display: none; }

/* ── Main Content Area ── */
.main-content {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  position: relative;
  z-index: 1;
  transition: margin-left 0.25s ease;
}

body.sidebar-collapsed .main-content { margin-left: var(--sidebar-w-collapsed); }

/* ── Topbar ── */
.topbar {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.75rem;
  height: var(--topbar-h);
  background: rgba(6, 8, 13, 0.88);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  z-index: 150;
  transition: left 0.25s ease;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.topbar-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* ── Agent Selector ── */
.agent-selector {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.4rem 0.75rem;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%238892a4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.6rem center;
  padding-right: 2rem;
}

.agent-selector:focus {
  border-color: var(--cyan);
}

.agent-selector option {
  background: var(--bg-card);
  color: var(--text-primary);
}

/* ================================================================
   LANDING NAV (index.html, docs.html)
   ================================================================ */
.landing-nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(6, 8, 13, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  will-change: transform;
  contain: layout style;
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
}

.nav-logo .claw-icon { width: 48px; height: 48px; object-fit: contain; filter: drop-shadow(0 0 8px var(--cyan)); }

.nav-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.1rem;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.nav-links { display: flex; gap: 2rem; list-style: none; }
.nav-links a {
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  transition: color 0.3s;
  font-weight: 500;
}
.nav-links a:hover,
.nav-links a:focus,
.nav-links a.active { color: var(--cyan); }

.nav-actions { display: flex; gap: 0.75rem; align-items: center; }

.nav-badge {
  padding: 0.35rem 0.9rem;
  border: 1px solid var(--border-cyan);
  border-radius: 100px;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--cyan);
  background: var(--cyan-glow);
  text-decoration: none;
  transition: all 0.3s;
  white-space: nowrap;
}
.nav-badge:hover,
.nav-badge:focus {
  background: rgba(0, 229, 255, 0.25);
  box-shadow: 0 0 20px rgba(0, 229, 255, 0.15);
}

.nav-badge.amber {
  border-color: rgba(255, 179, 0, 0.3);
  color: var(--amber);
  background: var(--amber-glow);
}
.nav-badge.amber:hover { background: rgba(255, 179, 0, 0.2); }

.nav-badge.green {
  border-color: rgba(0, 230, 118, 0.3);
  color: var(--green);
  background: rgba(0, 230, 118, 0.08);
}
.nav-badge.green:hover { background: rgba(0, 230, 118, 0.2); }

/* ================================================================
   SHARED COMPONENTS
   ================================================================ */

/* ── Status Indicators ── */
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
}

.status-dot.online {
  background: var(--green);
  box-shadow: 0 0 8px rgba(0, 230, 118, 0.5);
}

.status-dot.busy {
  background: var(--amber);
  box-shadow: 0 0 8px rgba(255, 179, 0, 0.5);
}

.status-dot.offline {
  background: var(--text-dim);
}

/* Accessible status text */
.status-dot::after {
  content: attr(data-status);
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
}

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.75rem;
  border-radius: 100px;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
}

.type-badge {
  padding: 0.15rem 0.6rem;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--purple-glow);
  color: var(--purple);
  border: 1px solid rgba(179, 136, 255, 0.2);
}

/* ── Origin Badges ── */
.origin-badge {
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.55rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.origin-deployed {
  background: rgba(0, 229, 255, 0.1);
  color: var(--cyan);
  border: 1px solid rgba(0, 229, 255, 0.25);
}
.origin-connected {
  background: rgba(0, 230, 118, 0.1);
  color: var(--green);
  border: 1px solid rgba(0, 230, 118, 0.25);
}
.origin-registered {
  background: rgba(187, 134, 252, 0.1);
  color: #bb86fc;
  border: 1px solid rgba(187, 134, 252, 0.25);
}

/* ── Cards ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
  transition: all 0.25s ease;
}

.card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-cyan);
  box-shadow: 0 0 20px var(--cyan-glow);
}

.card-title {
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 0.9rem;
  color: var(--cyan);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ── Form Controls ── */
.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  border-color: var(--border-cyan);
  box-shadow: 0 0 0 3px rgba(0, 229, 255, 0.08);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
  color: var(--text-dim);
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1.25rem;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
}

.btn-primary {
  background: var(--cyan);
  color: var(--bg-primary);
}

.btn-primary:hover {
  background: var(--cyan-dim);
  box-shadow: 0 0 16px var(--cyan-glow);
}

.btn-secondary {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  color: var(--text-primary);
  border-color: var(--border-cyan);
}

/* ── Modals ── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(8px);
  z-index: 200;
  justify-content: center;
  align-items: flex-start;
  padding: 40px 20px;
  overflow-y: auto;
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 100%;
  max-width: 760px;
  position: relative;
  animation: modalIn 0.3s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
}

.modal-close {
  width: 32px;
  height: 32px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.modal-close:hover {
  border-color: var(--red);
  color: var(--red);
}

.modal-body {
  padding: 24px;
}

/* ── Pulse Animation ── */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ── Focus Styles ── */
:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

/* ================================================================
   RESPONSIVE - MOBILE SIDEBAR
   ================================================================ */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    z-index: 300;
  }
  .sidebar.mobile-open {
    transform: translateX(0);
  }
  .main-content {
    margin-left: 0 !important;
  }
  .topbar {
    left: 0 !important;
  }
  .sidebar-toggle {
    display: none;
  }
}
