/* ⚖️ AI Court — Modern Clean Design */

:root {
  /* Modern dark theme - inspired by OpenAI/ChatGPT style */
  --bg-root: #1a1a2e;
  --bg-surface: #16213e;
  --bg-elevated: #1e293b;
  --bg-hover: #253349;

  /* Card colors */
  --card: #1e293b;
  --card-hover: #253349;
  --card-border: rgba(255, 255, 255, 0.06);

  /* Text colors - better contrast */
  --text: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  /* Accent colors - softer, more comfortable */
  --gold: #f59e0b;
  --gold-dark: #d97706;
  --gold-light: #fbbf24;
  --gold-dim: rgba(245, 158, 11, 0.15);

  --red: #ef4444;
  --red-dark: #dc2626;
  --red-light: #f87171;
  --red-dim: rgba(239, 68, 68, 0.15);

  --blue: #3b82f6;
  --blue-dark: #2563eb;
  --blue-light: #60a5fa;
  --blue-dim: rgba(59, 130, 246, 0.15);

  --green: #22c55e;
  --green-dark: #16a34a;
  --green-light: #4ade80;
  --green-dim: rgba(34, 197, 94, 0.15);

  --purple: #a855f7;
  --purple-dim: rgba(168, 85, 247, 0.15);

  /* Borders */
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.15);

  /* Radius */
  --r: 8px;
  --r-md: 12px;
  --r-lg: 16px;

  /* Shadows - subtle */
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.4);

  /* Transitions */
  --ease: 0.2s ease;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "Fira Code", "SF Mono", Menlo, Consolas, monospace;
}

/* ── Reset ─────────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 15px; -webkit-font-smoothing: antialiased; }

body {
  font-family: var(--font);
  background: var(--bg-root);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  overflow-x: hidden;
}

/* Subtle gradient background - much lighter than before */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background: radial-gradient(ellipse at top, rgba(59, 130, 246, 0.08) 0%, transparent 50%);
}

/* ── Typography ────────────────────────────────────── */
h1, h2, h3, h4 { font-weight: 700; line-height: 1.3; }
h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.2rem; }

a { color: var(--blue-light); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Buttons ───────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 24px;
  border: none;
  border-radius: var(--r);
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--ease);
  white-space: nowrap;
}

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

.btn-primary {
  background: linear-gradient(135deg, var(--blue), var(--blue-dark));
  color: white;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--blue-light), var(--blue));
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
  transform: translateY(-1px);
}

.btn-danger {
  background: linear-gradient(135deg, var(--red), var(--red-dark));
  color: white;
}

.btn-danger:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--red-light), var(--red));
}

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

.btn-outline:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--text);
  border-color: var(--border-strong);
}

/* Loading spinner */
.loading {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: white;
  animation: spin 0.8s linear infinite;
}

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

/* ── Index Page ────────────────────────────────────── */
.index-wrapper {
  max-width: 600px;
  margin: 0 auto;
  padding: 60px 24px;
  position: relative;
  z-index: 1;
}

.brand {
  text-align: center;
  margin-bottom: 48px;
}

.brand h1 {
  font-size: 2.5rem;
  margin-bottom: 12px;
  background: linear-gradient(135deg, var(--gold), var(--gold-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.brand p {
  color: var(--text-secondary);
  font-size: 1.1rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--r-lg);
  padding: 32px;
  box-shadow: var(--shadow-card);
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  color: var(--text);
  font-size: 0.9rem;
}

.form-group input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.95rem;
  transition: all var(--ease);
}

.form-group input:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-dim);
}

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

.error-msg {
  background: var(--red-dim);
  color: var(--red-light);
  padding: 12px 16px;
  border-radius: var(--r);
  margin-bottom: 20px;
  font-size: 0.9rem;
  border: 1px solid rgba(239, 68, 68, 0.2);
}

/* ── Debate Page ───────────────────────────────────── */
.debate-wrapper {
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: relative;
  z-index: 1;
}

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--gold);
}

.tb-icon {
  font-size: 1.3rem;
}

/* Progress bar */
.progress-bar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.progress-step {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-elevated);
  transition: all var(--ease);
}

.progress-step.active {
  background: var(--blue-dim);
  color: var(--blue-light);
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.progress-step.done {
  background: var(--green-dim);
  color: var(--green-light);
}

.step-num {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--bg-surface);
  font-size: 0.75rem;
}

.progress-step.active .step-num {
  background: var(--blue);
  color: white;
}

.progress-step.done .step-num {
  background: var(--green);
  color: white;
}

.progress-connector {
  width: 20px;
  height: 2px;
  background: var(--border);
}

.progress-connector.done {
  background: var(--green);
}

/* Three-column layout */
.debate-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Sidebar */
.debate-sidebar,
.debate-progress {
  width: 240px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  padding: 20px;
  overflow-y: auto;
  flex-shrink: 0;
}

.debate-progress {
  border-right: none;
  border-left: 1px solid var(--border);
}

.sidebar-section {
  margin-bottom: 24px;
}

.sidebar-section h3 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 12px;
  font-weight: 600;
}

.case-field {
  margin-bottom: 12px;
}

.field-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.field-value {
  font-size: 0.9rem;
  color: var(--text);
  font-weight: 500;
}

.model-claim {
  color: var(--gold);
}

/* Role legend */
.role-legend {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.role-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.role-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.role-legend-dot.prosecutor { background: var(--red); }
.role-legend-dot.defender { background: var(--blue); }
.role-legend-dot.judge { background: var(--gold); }
.role-legend-dot.jury { background: var(--purple); }

/* Chat window */
.debate-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-window {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  scroll-behavior: smooth;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  gap: 16px;
}

.empty-icon {
  font-size: 4rem;
  opacity: 0.5;
}

/* Message cards */
.message-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--r-md);
  margin-bottom: 16px;
  overflow: hidden;
  box-shadow: var(--shadow-card);
  transition: all var(--ease);
}

.message-card:hover {
  border-color: var(--border-strong);
}

/* Role-specific borders */
.message-card.role-prosecutor { border-left: 3px solid var(--red); }
.message-card.role-defender { border-left: 3px solid var(--blue); }
.message-card.role-judge { border-left: 3px solid var(--gold); }
.message-card.role-jury { border-left: 3px solid var(--purple); }

.message-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid var(--border);
}

.msg-role-icon {
  font-size: 1.2rem;
}

.msg-role-name {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text);
}

.msg-round {
  margin-left: auto;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--bg-surface);
  color: var(--text-secondary);
}

/* Think toggle */
.think-toggle-btn {
  margin-left: auto;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all var(--ease);
}

.think-toggle-btn:hover {
  background: var(--bg-hover);
  color: var(--text-secondary);
}

.think-toggle-btn.has-content {
  color: var(--gold);
  border-color: rgba(245, 158, 11, 0.3);
}

/* Think body */
.think-body {
  display: none;
  padding: 12px 16px;
  background: rgba(0, 0, 0, 0.15);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.6;
  max-height: 200px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.think-body.open {
  display: block;
}

/* Message body */
.message-card-body {
  padding: 16px;
  line-height: 1.7;
  color: var(--text);
}

.message-card-body p { margin-bottom: 12px; }
.message-card-body p:last-child { margin-bottom: 0; }

.message-card-body code {
  background: rgba(0, 0, 0, 0.3);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.85em;
}

.message-card-body pre {
  background: rgba(0, 0, 0, 0.3);
  padding: 16px;
  border-radius: var(--r);
  overflow-x: auto;
  margin: 12px 0;
}

.message-card-body pre code {
  background: none;
  padding: 0;
}

.message-card-body ul,
.message-card-body ol {
  padding-left: 24px;
  margin: 8px 0;
}

.message-card-body li {
  margin-bottom: 4px;
}

.message-card-body strong {
  color: var(--text);
  font-weight: 700;
}

.message-card-body blockquote {
  border-left: 3px solid var(--gold);
  padding-left: 16px;
  margin: 12px 0;
  color: var(--text-secondary);
}

/* System messages */
.system-message {
  text-align: center;
  padding: 8px 16px;
  margin-bottom: 12px;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-style: italic;
}

/* Verdict card */
.verdict-card {
  background: var(--card);
  border: 2px solid var(--gold);
  border-radius: var(--r-lg);
  padding: 32px;
  margin: 24px 0;
  text-align: center;
  box-shadow: 0 4px 20px rgba(245, 158, 11, 0.15);
}

.verdict-card h3 {
  color: var(--gold);
  margin-bottom: 16px;
  font-size: 1.1rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.verdict-result {
  font-size: 3rem;
  font-weight: 800;
  margin-bottom: 12px;
  padding: 16px 32px;
  border-radius: var(--r-md);
  display: inline-block;
}

.verdict-true {
  background: var(--green-dim);
  color: var(--green-light);
  border: 2px solid var(--green);
}

.verdict-false {
  background: var(--red-dim);
  color: var(--red-light);
  border: 2px solid var(--red);
}

.verdict-unknown {
  background: var(--gold-dim);
  color: var(--gold-light);
  border: 2px solid var(--gold);
}

.verdict-confidence {
  font-size: 1.1rem;
  color: var(--text-secondary);
  margin-bottom: 24px;
  font-weight: 600;
}

.verdict-votes {
  display: inline-flex;
  gap: 24px;
  padding: 12px 36px;
  margin-bottom: 32px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 30px;
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-weight: 600;
  border: 1px solid var(--border);
  font-family: var(--font-mono);
}

.verdict-votes strong { color: var(--text); }

/* Jury opinions */
.jury-opinions {
  text-align: left;
  margin-top: 16px;
}

.jury-opinion {
  background: rgba(255, 255, 255, 0.02);
  border-radius: var(--r);
  margin-bottom: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  transition: all var(--ease);
}

.jury-opinion:hover {
  border-color: var(--border-strong);
  background: rgba(255, 255, 255, 0.03);
}

.jury-opinion summary {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  list-style: none;
}

.jury-opinion summary::-webkit-details-marker { display: none; }

.jury-opinion summary::before {
  content: '▶';
  font-size: 0.7rem;
  color: var(--text-muted);
  transition: transform var(--ease);
}

.jury-opinion[open] summary::before {
  transform: rotate(90deg);
  color: var(--gold);
}

.jury-opinion .jury-label {
  color: var(--text);
  font-weight: 700;
  font-size: 0.88rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.jury-opinion .jury-vote {
  font-weight: 800;
  font-size: 0.88rem;
  text-transform: uppercase;
  font-family: var(--font-mono);
}

.jury-opinion .jury-confidence {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-left: auto;
  font-family: var(--font-mono);
}

.jury-opinion .jury-reason {
  padding: 16px;
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--text-secondary);
}

.jury-opinion.judge-opinion {
  border-left: 3px solid var(--gold);
}

/* Status bar */
.status-bar {
  display: flex;
  justify-content: space-between;
  padding: 8px 24px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* Action bar */
.action-bar {
  display: flex;
  justify-content: center;
  gap: 12px;
  padding: 16px 24px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* Streaming animation */
.message-card.streaming {
  animation: pulse 2s ease-in-out infinite;
}

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

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-surface);
}

::-webkit-scrollbar-thumb {
  background: var(--text-muted);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* ── Responsive ────────────────────────────────────── */
@media (max-width: 900px) {
  .debate-body {
    flex-direction: column;
  }

  .debate-sidebar,
  .debate-progress {
    width: 100%;
    border-right: none;
    border-left: none;
    border-bottom: 1px solid var(--border);
    padding: 12px 16px;
  }

  .debate-sidebar {
    order: 2;
  }

  .debate-main {
    order: 1;
    min-height: 400px;
  }

  .debate-progress {
    order: 3;
  }

  .progress-bar {
    display: none;
  }
}

@media (max-width: 600px) {
  .index-wrapper {
    padding: 32px 16px;
  }

  .brand h1 {
    font-size: 2rem;
  }

  .card {
    padding: 24px 16px;
  }

  .verdict-result {
    font-size: 2rem;
    padding: 12px 24px;
  }

  .verdict-votes {
    flex-direction: column;
    gap: 8px;
  }
}
