/* ui/css/styles.css */

/* Light Mode */
:root {
  --bg-background: 255 255 255;
  --bg-card: 242 244 248;
  --color-foreground: 23 23 23;
  --color-border: 220 220 230;
  --color-primary: 26 115 232;
  --color-secondary: 235 238 242;
  --color-muted: 100 116 139;
  --color-accent: 234 179 8;
  --color-agent-left: 14 165 233;
  --color-agent-right: 168 85 247;
  --color-emerald: 52 211 153;
}

/* Dark Mode */
.dark {
  /* DARK MODE*/
  --bg-background: 19 19 20;
  --bg-card: 30 31 32;
  --color-foreground: 227 227 227;
  /* Matches background, effectively invisible */
  --color-border: 19 19 20;
  --color-secondary: 40 41 42;
  --color-primary: 168 199 250;
  --color-muted: 156 163 175;
}

/* Base Styles */
* {
  box-sizing: border-box;
}

body {
  font-family: 'Inter', sans-serif;
  margin: 0;
  min-height: 100vh;
  background-color: rgb(var(--bg-background));
  color: rgb(var(--color-foreground));
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Typography */
h1 {
  font-family: 'Source Serif 4', serif;
  letter-spacing: -0.02em;
  font-weight: 600;
}

h2, h3, h4, h5, h6 {
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* Utilities */
.glass {
  background: rgba(var(--bg-card), 0.6);
  backdrop-filter: blur(16px);
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
}

.gradient-primary {
  background: linear-gradient(135deg, #4b90ff 0%, #d96570 100%);
}

/* Scrollbar */
.scrollbar-thin::-webkit-scrollbar {
  width: 6px;
}

.scrollbar-thin::-webkit-scrollbar-track {
  background: transparent;
}

.scrollbar-thin::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
}

/* Sidebar Transitions */
aside {
  transition: width 0.3s ease-in-out;
}

/* Expanded sidebar */
aside.sidebar-expanded {
  width: 16rem; /* 256px / w-64 */
}

/* Collapsed sidebar (icon-only) */
aside.sidebar-collapsed {
  width: 4rem; /* 64px - just enough for icons */
}

/* Hide text elements when collapsed */
aside.sidebar-collapsed .sidebar-text {
  opacity: 0;
  width: 0;
  overflow: hidden;
  white-space: nowrap;
}

/* Hide logo when collapsed */
aside.sidebar-collapsed .sidebar-title img {
  opacity: 0;
  width: 0;
  overflow: hidden;
}

/* Hide section headers when collapsed */
aside.sidebar-collapsed .sidebar-header h1 {
  opacity: 0;
  width: 0;
  overflow: hidden;
}

/* Hide recent debates placeholder text when collapsed */
aside.sidebar-collapsed #recentDebates {
  display: none;
}

/* Center all buttons and their content when collapsed */
aside.sidebar-collapsed .sidebar-btn {
  justify-content: center;
  padding-left: 0.75rem;
  padding-right: 0.75rem;
}

/* Ensure icons are centered */
aside.sidebar-collapsed .sidebar-btn svg {
  margin: 0 auto;
}

/* Center the user avatar */
aside.sidebar-collapsed .sidebar-btn > div {
  margin: 0 auto;
}

/* Center hamburger button */
aside.sidebar-collapsed .sidebar-header {
  justify-content: center;
}

aside.sidebar-collapsed #sidebarToggle {
  margin: 0 auto;
}

/* Show tooltips on hover when collapsed */
aside.sidebar-collapsed [title]:hover::after {
  content: attr(title);
  position: absolute;
  left: 100%;
  margin-left: 0.5rem;
  background: rgb(var(--bg-card));
  border: 1px solid rgb(var(--color-border));
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  white-space: nowrap;
  z-index: 50;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  font-size: 0.875rem;
  color: rgb(var(--color-foreground));
}

/* Debate Slide-in Panel (Artifact-style) */
.debate-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 45%;
  min-width: 400px;
  max-width: 800px;
  background: rgb(var(--bg-background));
  border-left: 1px solid rgb(var(--color-border));
  transform: translateX(100%);
  transition: transform 0.3s ease-in-out;
  z-index: 40;
  display: flex;
  flex-direction: column;
  box-shadow: -4px 0 12px rgba(0, 0, 0, 0.1);
}

.debate-panel.active {
  transform: translateX(0);
}

/* Stop Simulation button */
.stop-simulation-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}
.stop-simulation-btn:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.5);
}
.stop-simulation-btn.hidden {
  display: none;
}

/* Shrink main content when debate panel is active */
body:has(.debate-panel.active) main {
  margin-right: 45%;
  transition: margin-right 0.3s ease-in-out;
}

@media (min-width: 1400px) {
  body:has(.debate-panel.active) main {
    margin-right: 800px;
  }
}

@media (max-width: 1200px) {
  body:has(.debate-panel.active) main {
    margin-right: 400px;
  }
}

/* Overlay for debate panel - REMOVED, no longer needed */
.debate-overlay {
  display: none;
}

/* Responsive - full width on mobile, overlay main content */
@media (max-width: 768px) {
  .debate-panel {
    width: 100%;
    min-width: 100%;
  }

  body:has(.debate-panel.active) main {
    margin-right: 0;
  }

  /* Show overlay on mobile */
  .debate-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease-in-out;
    z-index: 35;
  }

  .debate-overlay.active {
    opacity: 1;
    pointer-events: auto;
  }
}

/* Debate Modal Styles (keeping for backwards compatibility but deprecated) */
.debate-modal {
  animation: modalFadeIn 0.3s ease-out;
}

@keyframes modalFadeIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Removed fade-in animation for debate messages - messages should appear instantly after typing indicator for smooth Claude-like flow */
.debate-message {
  /* No animation - instant appearance */
  margin-bottom: 0.75rem;
}

/* ── Chat-bubble directional styling (messaging-app look) ────────── */

/* Left-aligned bubble: flat top-left corner + colored accent strip */
.chat-bubble-left {
  border-radius: 0.25rem 1rem 1rem 1rem;
  border-left: 3px solid rgb(var(--color-agent-left)) !important;
}

/* Right-aligned bubble: flat top-right corner + colored accent strip */
.chat-bubble-right {
  border-radius: 1rem 0.25rem 1rem 1rem;
  border-right: 3px solid rgb(var(--color-agent-right)) !important;
}

/* Center-aligned bubble (Chief Justice / system): symmetric + colored accent strip */
.chat-bubble-center {
  border-radius: 1rem;
  border-bottom: 3px solid rgb(var(--color-primary)) !important;
}

/* ── Rich-text formatting inside debate / chat messages ────────────── */
.debate-message-text ul,
.debate-message-text ol,
.typing-content ul,
.typing-content ol {
  margin: 0.5em 0;
  padding-left: 1.5em;
}

.debate-message-text ul,
.typing-content ul {
  list-style-type: disc;
}

.debate-message-text ol,
.typing-content ol {
  list-style-type: decimal;
}

.debate-message-text li,
.typing-content li {
  margin-bottom: 0.35em;
  padding-left: 0.25em;
  line-height: 1.55;
}

/* Nested lists */
.debate-message-text ul ul,
.typing-content ul ul {
  list-style-type: circle;
  margin-top: 0.25em;
}

.debate-message-text ul ul ul,
.typing-content ul ul ul {
  list-style-type: square;
}

/* Headings inside messages (e.g. "ROUND 2:", "Unresolved Tensions:") */
.debate-message-text h1,
.debate-message-text h2,
.debate-message-text h3,
.debate-message-text h4,
.typing-content h1,
.typing-content h2,
.typing-content h3,
.typing-content h4 {
  font-weight: 700;
  margin: 0.75em 0 0.35em;
  line-height: 1.3;
}

.debate-message-text h1, .typing-content h1 { font-size: 1.15em; }
.debate-message-text h2, .typing-content h2 { font-size: 1.08em; }
.debate-message-text h3, .typing-content h3 { font-size: 1.02em; }
.debate-message-text h4, .typing-content h4 { font-size: 0.95em; }

/* Paragraphs inside messages */
.debate-message-text p,
.typing-content p {
  margin: 0.4em 0;
}

/* Bold / strong */
.debate-message-text strong,
.typing-content strong {
  font-weight: 600;
  color: rgb(var(--color-foreground));
}

/* Fade-in animation for agent name and round when they appear */
.agent-header-fade {
  animation: agentHeaderFadeIn 0.3s ease-out;
}

@keyframes agentHeaderFadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.typing-indicator {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  animation: typingBounce 1.4s infinite;
}

.typing-indicator span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typingBounce {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.7;
  }
  30% {
    transform: translateY(-10px);
    opacity: 1;
  }
}

.pulse-glow {
  animation: pulseGlow 2s ease-in-out infinite;
}

@keyframes pulseGlow {
  0%, 100% {
    opacity: 0.6;
  }
  50% {
    opacity: 1;
  }
}

/* Smooth scroll behavior — the browser handles the animation;
   JS just sets scrollTop and this CSS does the rest.          */
.debate-chat-container,
#chatMessagesContainer {
  scroll-behavior: smooth;
}

/* Verdict animation */
.verdict-reveal {
  animation: verdictFadeIn 0.6s ease-out;
}

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

/* Fade in animation */
.animate-in {
  animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Line clamp utility */
.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Shimmer animation for AI suggestions */
@keyframes shimmer {
  0%, 100% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
}

/* Responsive sidebar */
@media (max-width: 1024px) {
  aside.sidebar-open {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 40;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
  }
}

/* ── Help / Tutorial Modal ─────────────────────────────────────────────── */

/* Step indicator dots */
.help-step-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: rgb(var(--color-secondary));
  transition: background 0.3s ease, transform 0.2s ease;
  padding: 0;
}

.help-step-dot.active {
  background: linear-gradient(135deg, #4b90ff 0%, #d96570 100%);
  transform: scale(1.3);
}

.help-step-dot:hover:not(.active) {
  background: rgb(var(--color-muted));
}

/* Step content fade + slide transition */
.help-step-fade {
  animation: helpStepIn 0.35s ease-out;
}

@keyframes helpStepIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Tab pills */
.help-tab-pill {
  color: rgb(var(--color-muted));
  cursor: pointer;
  border: none;
  background: transparent;
}

.help-tab-pill.active {
  background: rgb(var(--bg-background));
  color: rgb(var(--color-foreground));
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.help-tab-pill:hover:not(.active) {
  color: rgb(var(--color-foreground));
}

/* FAQ accordion body */
.faq-item-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.faq-item.open .faq-item-body {
  max-height: 300px;
}

.faq-item.open .faq-chevron {
  transform: rotate(180deg);
}