/* Trust Ledger v0.2 Styles */

:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-hover: #334155;
  --border: #334155;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius: 8px;
  --shadow: 0 4px 20px rgba(0,0,0,0.3);
}

[data-theme="light"] {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-hover: #f1f5f9;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #64748b;
  --shadow: 0 4px 20px rgba(0,0,0,0.08);
}

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

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

#app { max-width: 900px; margin: 0 auto; padding: 1.5rem; }

/* Header */
header { margin-bottom: 1.5rem; }
.header-main {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}
h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; }
#stats-banner { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 1rem; }

.icon-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.4rem 0.6rem;
  cursor: pointer;
  font-size: 1.1rem;
  transition: all 0.2s;
}
.icon-btn:hover { background: var(--surface-hover); }

/* Filter */
.filter-wrapper { margin-bottom: 1rem; }
#global-search {
  width: 100%;
  padding: 0.6rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.9rem;
}
#global-search:focus { outline: none; border-color: var(--accent); }

/* Tabs */
.tab-nav {
  display: flex;
  gap: 0.5rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
  margin-bottom: 1.5rem;
}
.nav-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.2s;
}
.nav-btn:hover { color: var(--text); background: var(--surface); }
.nav-btn.active { color: var(--text); background: var(--surface); font-weight: 600; }

.tab-panel.hidden { display: none; }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}
.card h2 { font-size: 1.1rem; margin-bottom: 1rem; display: flex; align-items: center; gap: 0.5rem; }
.subtitle { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 1rem; margin-top: -0.5rem; }

/* Form */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.input-group { margin-bottom: 1rem; }
.input-group label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}
.input-group input,
.input-group select,
.input-group textarea {
  width: 100%;
  padding: 0.55rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
}
.input-group input:focus,
.input-group select:focus,
.input-group textarea:focus { outline: none; border-color: var(--accent); }

input[type="range"] { accent-color: var(--accent); }
.range-value { display: inline-block; width: 2rem; text-align: center; font-weight: 600; margin-left: 0.5rem; }

.radios { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 1rem; }
.pill-radio {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.9rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}
.pill-radio:hover { border-color: var(--accent); }
.pill-radio input { accent-color: var(--accent); }

.submit-btn, .export-btn, .secondary-btn, .danger-btn {
  padding: 0.6rem 1.2rem;
  border: none;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.submit-btn { background: var(--accent); color: white; }
.submit-btn:hover { background: var(--accent-hover); }
.export-btn { background: var(--surface-hover); color: var(--text); margin-right: 0.5rem; margin-bottom: 0.5rem; }
.export-btn:hover { background: var(--border); }
.secondary-btn { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.secondary-btn:hover { background: var(--surface-hover); }
.danger-btn { background: #7f1d1d; color: #fee2e2; }
.danger-btn:hover { background: #991b1b; }

.btn-row { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* Ledger Entries */
.ledger-list { display: flex; flex-direction: column; gap: 0.75rem; }
.ledger-entry {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  transition: all 0.2s;
}
.ledger-entry:hover { border-color: var(--surface-hover); }

.entry-header {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 0.6rem;
  font-size: 0.8rem;
}
.entry-model { font-weight: 700; color: var(--accent); }
.entry-context {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--surface);
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  color: var(--text-muted);
}
.entry-status { font-size: 1rem; }
.entry-trust { color: var(--warning); letter-spacing: 2px; font-size: 0.85rem; }
.entry-date { margin-left: auto; color: var(--text-muted); font-size: 0.75rem; }

.entry-body { font-size: 0.85rem; }
.entry-prompt, .entry-response { margin-bottom: 0.4rem; word-break: break-word; }
.entry-correction {
  background: rgba(239,68,68,0.08);
  border-left: 3px solid var(--danger);
  padding: 0.5rem 0.75rem;
  margin-top: 0.5rem;
  border-radius: 0 4px 4px 0;
  font-size: 0.8rem;
}

.entry-meta { margin-top: 0.6rem; display: flex; gap: 0.4rem; flex-wrap: wrap; align-items: center; }
.tag {
  font-size: 0.7rem;
  background: var(--surface);
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  color: var(--text-muted);
}
.badge {
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-weight: 600;
}
.badge.correction { background: rgba(239,68,68,0.15); color: var(--danger); }
.badge.confidence.low { background: #fee2e2; color: #991b1b; }
.badge.confidence.medium { background: #fef3c7; color: #92400e; }
.badge.confidence.high { background: #d1fae5; color: #065f46; }

.entry-actions { margin-top: 0.75rem; display: flex; gap: 0.5rem; }
.action-btn {
  padding: 0.35rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-size: 0.8rem;
  cursor: pointer;
}
.action-btn:hover { background: var(--surface-hover); }
.action-btn.danger { color: var(--danger); border-color: rgba(239,68,68,0.3); }
.action-btn.danger:hover { background: rgba(239,68,68,0.1); }

/* Model of You */
#model-of-you-editor {
  font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
  font-size: 0.8rem;
  line-height: 1.6;
  background: var(--bg);
}

.validation-msg { margin-top: 0.5rem; font-size: 0.9rem; }
.validation-msg.success { color: var(--success); }
.validation-msg.error { color: var(--danger); }

.correction-list { display: flex; flex-direction: column; gap: 0.5rem; }
.correction-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.75rem;
  font-size: 0.85rem;
}
.correction-date { font-size: 0.75rem; color: var(--text-muted); margin-bottom: 0.3rem; }
.strike { text-decoration: line-through; opacity: 0.6; }
.correct { color: var(--success); font-weight: 500; }

/* Charts */
.chart-row { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.6rem; font-size: 0.85rem; }
.chart-row .lbl { width: 80px; font-weight: 500; }
.bar-bg { flex: 1; height: 10px; background: var(--bg); border-radius: 5px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 5px; transition: width 0.5s ease; }
.bar-fill.cyan { background: #06b6d4; }
.bar-fill.blue { background: var(--accent); }
.bar-fill.purple { background: #a855f7; }
.bar-fill.grey { background: #64748b; }
.bar-fill.red { background: var(--danger); }
.bar-fill.orange { background: var(--warning); }
.bar-fill.green { background: var(--success); }
.val { width: 40px; text-align: right; font-size: 0.8rem; color: var(--text-muted); }

/* Trust Scores */
.scores-list { display: flex; flex-direction: column; gap: 1rem; }
.score-group h4 { margin: 0 0 0.5rem 0; font-size: 0.95rem; }
.score-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.85rem;
  margin-bottom: 0.4rem;
}
.score-row span:first-child { width: 80px; }
.score-bar-wrap { flex: 1; height: 8px; background: var(--bg); border-radius: 4px; overflow: hidden; }
.score-bar { height: 100%; border-radius: 4px; transition: width 0.4s ease; }
.score-detail { font-size: 0.75rem; color: var(--text-muted); margin-left: 0.5rem; }

/* Timeline */
.timeline-container { display: flex; align-items: flex-end; gap: 1rem; height: 140px; padding-top: 1rem; }
.timeline-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 0.5rem; }
.timeline-bar { width: 100%; background: var(--accent); border-radius: 4px 4px 0 0; min-height: 4px; transition: height 0.4s ease; opacity: 0.8; }
.timeline-label { font-size: 0.75rem; color: var(--text-muted); }
.timeline-val { font-size: 0.85rem; font-weight: 600; }

/* Data Panel */
.import-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}
.import-zone:hover { border-color: var(--accent); background: var(--bg); }
.import-label { cursor: pointer; color: var(--text-muted); font-size: 0.9rem; }
.import-label span { display: block; }

/* Empty State */
.empty-state { color: var(--text-muted); font-style: italic; padding: 1.5rem 0; text-align: center; font-size: 0.9rem; }

/* Animations */
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(59,130,246,0.4); }
  70% { box-shadow: 0 0 0 10px rgba(59,130,246,0); }
  100% { box-shadow: 0 0 0 0 rgba(59,130,246,0); }
}

/* Responsive */
@media (max-width: 600px) {
  #app { padding: 1rem; }
  .form-row { grid-template-columns: 1fr; }
  .tab-nav { overflow-x: auto; }
  .entry-header { gap: 0.4rem; }
  .entry-date { margin-left: 0; width: 100%; }
  .timeline-container { height: 100px; }
}
