:root {
  --bg-main: #0a0d14;
  --bg-sidebar: #0f1420;
  --bg-card: rgba(18, 24, 38, 0.75);
  --bg-card-hover: rgba(28, 36, 56, 0.85);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-active: rgba(99, 102, 241, 0.4);
  
  --primary: #4f46e5;
  --primary-glow: rgba(79, 70, 229, 0.35);
  --primary-gradient: linear-gradient(135deg, #4f46e5 0%, #6366f1 50%, #8b5cf6 100%);
  
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --text-dim: #6b7280;

  --emerald: #10b981;
  --emerald-bg: rgba(16, 185, 129, 0.12);
  --amber: #f59e0b;
  --amber-bg: rgba(245, 158, 11, 0.12);
  --rose: #f43f5e;
  --rose-bg: rgba(244, 63, 94, 0.12);
  --purple: #a855f7;
  --purple-bg: rgba(168, 85, 247, 0.12);

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-heading: 'Outfit', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: var(--text-main);
  height: 100vh;
  overflow: hidden;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* App Layout */
.app-layout {
  display: flex;
  height: 100vh;
  width: 100vw;
}

/* Sidebar */
.sidebar {
  width: 320px;
  min-width: 300px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  padding: 24px 20px;
  gap: 24px;
  z-index: 10;
}

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

.logo-badge {
  width: 44px;
  height: 44px;
  background: var(--primary-gradient);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: 0 4px 16px var(--primary-glow);
}

.brand-title {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #ffffff 0%, #cbd5e1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-subtitle {
  font-size: 0.78rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.btn-new-chat {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-new-chat:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--border-active);
  transform: translateY(-1px);
}

/* Control Panel */
.control-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px;
}

.section-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #818cf8;
}

.temporal-selector {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.radio-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
}

.radio-option:hover {
  background: rgba(255, 255, 255, 0.03);
}

.radio-option input[type="radio"] {
  display: none;
}

.radio-custom {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--text-dim);
  margin-top: 3px;
  position: relative;
  flex-shrink: 0;
  transition: border-color 0.2s;
}

.radio-option input[type="radio"]:checked + .radio-custom {
  border-color: #6366f1;
}

.radio-option input[type="radio"]:checked + .radio-custom::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #6366f1;
}

.radio-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.radio-text strong {
  font-size: 0.85rem;
  color: var(--text-main);
}

.radio-text small {
  font-size: 0.74rem;
  color: var(--text-dim);
  line-height: 1.3;
}

.custom-date-container {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-top: 1px solid var(--border-subtle);
  padding-top: 12px;
}

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

.date-input {
  width: 100%;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: white;
  font-family: var(--font-sans);
  font-size: 0.85rem;
}

.date-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.chip {
  padding: 4px 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 0.72rem;
  cursor: pointer;
  transition: all 0.15s;
}

.chip:hover {
  background: var(--primary-glow);
  border-color: #6366f1;
  color: white;
}

/* System Status Card */
.system-status-card {
  margin-top: auto;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.status-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
}

.status-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
}

.stage-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.badge {
  font-size: 0.68rem;
  padding: 3px 8px;
  border-radius: 6px;
  font-weight: 600;
}

.stage-1 { background: rgba(59, 130, 246, 0.15); color: #60a5fa; }
.stage-2 { background: rgba(139, 92, 246, 0.15); color: #a78bfa; }
.stage-3 { background: rgba(16, 185, 129, 0.15); color: #34d399; }
.stage-4 { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }

.status-meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.coverage-bar {
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  overflow: hidden;
}

.coverage-fill {
  height: 100%;
  background: linear-gradient(90deg, #10b981, #6366f1);
  transition: width 0.3s;
}

/* Main Chat Window */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: relative;
  background: radial-gradient(circle at 50% 0%, rgba(99, 102, 241, 0.06) 0%, transparent 60%);
}

.chat-header {
  height: 70px;
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(11, 15, 25, 0.6);
  backdrop-filter: blur(16px);
  z-index: 5;
}

.header-info h2 {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 700;
}

.active-badge-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.indicator-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #6366f1;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-link {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--border-subtle);
  transition: all 0.2s;
}

.header-link:hover {
  background: rgba(255, 255, 255, 0.05);
  color: white;
}

.btn-export-header {
  background: rgba(16, 185, 129, 0.12);
  color: #6ee7b7;
  border: 1px solid rgba(16, 185, 129, 0.3);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  font-weight: 500;
  font-family: inherit;
}

.btn-export-header:hover {
  background: rgba(16, 185, 129, 0.22);
  color: #a7f3d0;
  border-color: rgba(16, 185, 129, 0.5);
}

.docker-badge {
  font-size: 0.72rem;
  font-family: var(--font-mono);
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

/* Messages Area */
.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Welcome Hero */
.welcome-hero {
  max-width: 780px;
  margin: 40px auto;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.welcome-icon {
  font-size: 3rem;
  filter: drop-shadow(0 0 20px rgba(99, 102, 241, 0.4));
}

.welcome-hero h3 {
  font-family: var(--font-heading);
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.welcome-hero p {
  color: var(--text-muted);
  font-size: 1rem;
  max-width: 620px;
  line-height: 1.6;
}

.suggestions-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin-top: 24px;
  width: 100%;
  text-align: left;
}

.suggestion-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.suggestion-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-active);
  background: var(--bg-card-hover);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.sug-badge {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 4px;
  align-self: flex-start;
  background: rgba(99, 102, 241, 0.15);
  color: #818cf8;
}

.sug-badge.temporal { background: var(--amber-bg); color: var(--amber); }
.sug-badge.alert { background: var(--rose-bg); color: var(--rose); }

.suggestion-card h4 {
  font-size: 0.95rem;
  font-weight: 600;
  color: #fff;
}

.suggestion-card p {
  font-size: 0.8rem;
  color: var(--text-dim);
  line-height: 1.4;
}

/* Chat Message Bubbles */
.message-row {
  display: flex;
  gap: 16px;
  max-width: 860px;
  width: 100%;
  margin: 0 auto;
  animation: fadeIn 0.3s ease forwards;
}

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

.message-row.user {
  justify-content: flex-end;
}

.message-avatar {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-weight: 700;
  font-size: 0.95rem;
}

.message-row.assistant .message-avatar {
  background: var(--primary-gradient);
  color: white;
  box-shadow: 0 4px 12px var(--primary-glow);
}

.message-row.user .message-avatar {
  display: none;
}

.message-bubble {
  padding: 16px 20px;
  border-radius: var(--radius-lg);
  font-size: 0.94rem;
  line-height: 1.6;
  max-width: 760px;
}

.message-row.user .message-bubble {
  background: var(--primary-gradient);
  color: white;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 16px var(--primary-glow);
}

.message-row.assistant .message-bubble {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-bottom-left-radius: 4px;
  color: #e5e7eb;
}

.message-bubble strong {
  color: #fff;
}

.message-bubble p {
  margin-bottom: 10px;
}

.message-bubble p:last-child {
  margin-bottom: 0;
}

/* Citations Container */
.citations-box {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-top: 1px solid var(--border-subtle);
  padding-top: 12px;
}

.citations-title {
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #818cf8;
  display: flex;
  align-items: center;
  gap: 6px;
}

.citations-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.citation-card {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.citation-card:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--border-active);
}

.citation-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.citation-law {
  font-weight: 700;
  font-size: 0.88rem;
  color: #fff;
}

.validity-badge {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 6px;
  font-weight: 600;
  white-space: nowrap;
}

.validity-badge.active {
  background: var(--emerald-bg);
  color: var(--emerald);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.validity-badge.repealed {
  background: var(--amber-bg);
  color: var(--amber);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.validity-badge.future {
  background: var(--purple-bg);
  color: var(--purple);
  border: 1px solid rgba(168, 85, 247, 0.3);
}

.validity-badge.date-required {
  background: var(--rose-bg);
  color: var(--rose);
  border: 1px solid rgba(244, 63, 94, 0.3);
}

.citation-summary {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.citation-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
  font-size: 0.72rem;
}

.citation-rrf {
  font-family: var(--font-mono);
  color: #818cf8;
}

.citation-action {
  color: #60a5fa;
  font-weight: 600;
}

/* Typing / Loading state */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-dim);
  font-size: 0.85rem;
  padding: 12px 16px;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(99, 102, 241, 0.2);
  border-top-color: #6366f1;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Input Area */
.input-container {
  padding: 20px 32px 28px;
  background: linear-gradient(to top, var(--bg-main) 70%, transparent);
}

.chat-form {
  max-width: 860px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.input-box-wrapper {
  display: flex;
  align-items: flex-end;
  background: rgba(18, 24, 38, 0.85);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 10px 14px 10px 20px;
  transition: all 0.2s ease;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.input-box-wrapper:focus-within {
  border-color: #6366f1;
  box-shadow: 0 4px 24px var(--primary-glow);
}

.chat-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: white;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  resize: none;
  max-height: 160px;
  line-height: 1.5;
}

.chat-input::placeholder {
  color: var(--text-dim);
}

.btn-send {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--primary-gradient);
  border: none;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
  box-shadow: 0 2px 8px var(--primary-glow);
}

.btn-send:hover {
  transform: scale(1.05);
}

.btn-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.input-footer {
  display: flex;
  justify-content: space-between;
  font-size: 0.74rem;
  color: var(--text-dim);
  padding: 0 8px;
}

.rag-indicator {
  color: #818cf8;
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
}

.modal-card {
  background: #111827;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 680px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
  animation: modalIn 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

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

.modal-pretitle {
  font-size: 0.78rem;
  color: var(--text-dim);
  text-transform: uppercase;
}

.modal-header h3 {
  font-family: var(--font-heading);
  font-size: 1.2rem;
  color: #fff;
  margin-top: 2px;
}

.btn-close {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}

.btn-close:hover {
  color: white;
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.modal-badge-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.rrf-badge {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(99, 102, 241, 0.15);
  color: #818cf8;
}

.modal-section h4 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.plain-summary-box {
  background: rgba(255, 255, 255, 0.03);
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  color: #e5e7eb;
  font-size: 0.88rem;
  border-left: 3px solid #6366f1;
}

.sanctions-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sanctions-list li {
  font-size: 0.85rem;
  color: #fbbf24;
  display: flex;
  align-items: center;
  gap: 6px;
}

.sanctions-list li::before {
  content: '⚠️';
  font-size: 0.75rem;
}

.legal-body-box {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 14px;
  font-size: 0.86rem;
  color: #cbd5e1;
  white-space: pre-wrap;
  line-height: 1.6;
  max-height: 250px;
  overflow-y: auto;
}
