/**
 * SINT Dashboard — Styles.
 *
 * Dark theme with security-focused color palette.
 * CSS custom properties for easy theming.
 */

/* ── Design Tokens ── */

:root {
  --bg-primary: #0a0e17;
  --bg-secondary: #111827;
  --bg-card: #1a2332;
  --bg-card-hover: #1f2b3d;

  --border: #2a3548;
  --border-active: #3b4d66;

  --text-primary: #e8edf5;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;

  --accent: #60a5fa;
  --accent-dim: rgba(96, 165, 250, 0.15);

  --success: #34d399;
  --warning: #fbbf24;
  --danger: #f87171;
  --info: #818cf8;

  --tier-0: #34d399;
  --tier-1: #60a5fa;
  --tier-2: #fbbf24;
  --tier-3: #f87171;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);

  --font-mono: "JetBrains Mono", "Fira Code", "SF Mono", "Consolas", monospace;
  --font-sans: "Inter", -apple-system, "Segoe UI", sans-serif;

  --transition: 180ms ease;
}

/* ── Reset & Base ── */

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

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: rgba(255, 255, 255, 0.06);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}

/* ── Header ── */

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}

.header-left,
.header-center,
.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.1rem;
  font-weight: 700;
}

.logo-icon {
  font-size: 1.4rem;
}

.logo-text {
  color: var(--accent);
  letter-spacing: 0.08em;
}

.logo-sub {
  color: var(--text-muted);
  font-weight: 400;
  font-size: 0.85rem;
}

.pending-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(251, 191, 36, 0.15);
  border: 1px solid rgba(251, 191, 36, 0.3);
  border-radius: 20px;
  padding: 4px 14px;
  animation: badge-enter 300ms ease;
}

@keyframes badge-enter {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.badge-pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warning);
  animation: pulse 1.5s ease infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.4;
  }
}

.badge-count {
  font-weight: 700;
  color: var(--warning);
  font-size: 0.95rem;
}

.badge-label {
  color: var(--text-secondary);
  font-size: 0.8rem;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  transition: background var(--transition);
}

.status-dot.connected {
  background: var(--success);
  box-shadow: 0 0 8px rgba(52, 211, 153, 0.5);
}

.status-dot.disconnected {
  background: var(--danger);
}

.status-label {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.health-stats {
  display: flex;
  gap: 12px;
  margin-left: 12px;
  padding-left: 12px;
  border-left: 1px solid var(--border);
}

.stat {
  font-size: 0.8rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 4px;
}

.stat-icon {
  font-size: 0.85rem;
}

/* ── Layout ── */

.dashboard {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

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

/* ── Panels ── */

.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.panel-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-count {
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
}

.panel-meta {
  margin-left: auto;
  font-size: 0.8rem;
  font-weight: 500;
}

.chain-ok {
  color: var(--success);
}

.chain-broken {
  color: var(--danger);
}

.panel-footer {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
}

/* ── Policy Playground ── */

.playground-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.playground-help {
  font-size: 0.85rem;
}

.playground-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 960px) {
  .playground-grid {
    grid-template-columns: 1fr;
  }
}

.playground-label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.playground-textarea {
  width: 100%;
  min-height: 220px;
  resize: vertical;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.5;
  padding: 10px 12px;
}

.playground-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(96, 165, 250, 0.15);
}

.playground-textarea-readonly {
  opacity: 0.95;
}

.playground-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

/* ── Overview Cards ── */

.overview-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}

.overview-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.overview-card:hover {
  border-color: var(--border-active);
  box-shadow: var(--shadow-md);
}

.card-icon {
  font-size: 1.6rem;
  flex-shrink: 0;
}

.card-content {
  display: flex;
  flex-direction: column;
}

.card-value {
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1.2;
}

.card-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ── Pending Approvals ── */

.approval-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.approval-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  transition: border-color var(--transition);
}

.approval-card:hover {
  border-color: var(--border-active);
}

.approval-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.tier-badge {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 3px 10px;
  border-radius: 4px;
  color: var(--bg-primary);
}

.approval-timer {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.approval-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.approval-field {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.field-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  min-width: 70px;
  flex-shrink: 0;
}

.field-value {
  font-size: 0.85rem;
  color: var(--text-secondary);
  word-break: break-all;
}

.agent-id {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.approval-actions {
  display: flex;
  gap: 8px;
}

/* ── Buttons ── */

.btn {
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 8px 20px;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  letter-spacing: 0.02em;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

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

.btn-approve:hover:not(:disabled) {
  background: #4ae8aa;
  box-shadow: 0 0 12px rgba(52, 211, 153, 0.3);
}

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

.btn-deny:hover:not(:disabled) {
  background: rgba(248, 113, 113, 0.1);
}

/* ── Audit Log ── */

.audit-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 400px;
  overflow-y: auto;
}

.audit-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  transition: background var(--transition);
}

.audit-row:hover {
  background: var(--bg-card-hover);
}

.audit-icon {
  font-size: 0.9rem;
  flex-shrink: 0;
}

.audit-time {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  flex-shrink: 0;
  min-width: 65px;
}

.audit-type {
  font-weight: 600;
  font-size: 0.78rem;
  flex-shrink: 0;
  min-width: 160px;
}

.audit-agent {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  flex-shrink: 0;
  min-width: 120px;
}

.audit-detail {
  font-size: 0.75rem;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Tier Legend ── */

.tier-legend {
  background: transparent;
  border: 1px dashed var(--border);
}

.tier-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tier-item {
  display: flex;
  align-items: center;
  gap: 12px;
}

.tier-indicator {
  font-size: 0.7rem;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  color: var(--bg-primary);
  text-align: center;
  min-width: 38px;
}

.tier-info {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.tier-name {
  font-weight: 600;
  font-size: 0.85rem;
}

.tier-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.tier-auto {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
}

.auto-yes {
  background: rgba(52, 211, 153, 0.12);
  color: var(--success);
}

.auto-no {
  background: rgba(251, 191, 36, 0.12);
  color: var(--warning);
}

/* ── Empty & Loading States ── */

.empty-state {
  text-align: center;
  padding: 32px 16px;
}

.empty-icon {
  font-size: 2.5rem;
  display: block;
  margin-bottom: 8px;
}

.text-muted {
  color: var(--text-muted);
}

.loading {
  text-align: center;
  padding: 20px;
  color: var(--text-muted);
}

.error-banner {
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid rgba(248, 113, 113, 0.3);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-size: 0.85rem;
  color: var(--danger);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Scrollbar ── */

.audit-list::-webkit-scrollbar {
  width: 6px;
}

.audit-list::-webkit-scrollbar-track {
  background: transparent;
}

.audit-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.audit-list::-webkit-scrollbar-thumb:hover {
  background: var(--border-active);
}

/* ── Login Screen ── */

.login-backdrop {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  padding: 24px;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.login-header {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.login-icon {
  font-size: 2.5rem;
  display: block;
  margin-bottom: 4px;
}

.login-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.06em;
}

.login-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.login-error {
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid rgba(248, 113, 113, 0.3);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.82rem;
  color: var(--danger);
  display: flex;
  align-items: center;
  gap: 6px;
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.login-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.login-input {
  font-family: var(--font-mono);
  font-size: 0.88rem;
  padding: 10px 14px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.login-input::placeholder {
  color: var(--text-muted);
}

.login-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.15);
}

.login-input:disabled {
  opacity: 0.5;
}

.login-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.login-btn {
  width: 100%;
  padding: 12px;
  font-size: 0.9rem;
  font-weight: 700;
  background: var(--accent);
  color: var(--bg-primary);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  letter-spacing: 0.03em;
}

.login-btn:hover:not(:disabled) {
  background: #7bb8ff;
  box-shadow: 0 0 16px rgba(96, 165, 250, 0.3);
}

.login-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.login-footer {
  text-align: center;
}

.login-protocol {
  font-size: 0.7rem;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ── Operator Badge (Header) ── */

.operator-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: 12px;
  padding-left: 12px;
  border-left: 1px solid var(--border);
}

.operator-icon {
  font-size: 0.85rem;
}

.operator-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-logout {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.75rem;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  margin-left: 4px;
}

.btn-logout:hover {
  border-color: var(--danger);
  color: var(--danger);
  background: rgba(248, 113, 113, 0.1);
}
