:root {
  --td-primary: #042D49;
  --td-primary-dark: #001020;
  --td-accent: #F4CC04;
  --td-accent-hover: #E5BD00;
  --td-surface: #0A1929;
  --td-card: #0D2137;
  --td-card-border: #163354;
  --td-input: #0E1E33;
  --td-input-border: #1E3A5F;
}

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

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--td-primary-dark); }
::-webkit-scrollbar-thumb { background: var(--td-card-border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--td-input-border); }

.page-section { transition: opacity 0.2s ease-in-out; }

.chat-bubble { animation: slideUp 0.3s ease-out; }
@keyframes slideUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.toast-enter { animation: toastIn 0.3s ease-out; }
.toast-exit { animation: toastOut 0.3s ease-in forwards; }
@keyframes toastIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes toastOut { from { transform: translateX(0); opacity: 1; } to { transform: translateX(100%); opacity: 0; } }

.status-pulse { animation: pulse 2s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

.json-viewer {
  background: var(--td-primary-dark);
  border: 1px solid var(--td-card-border);
  border-radius: 0.75rem;
  padding: 1rem;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.75rem;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 400px;
  overflow-y: auto;
}
.json-key { color: #F4CC04; }
.json-string { color: #86efac; }
.json-number { color: #93c5fd; }
.json-boolean { color: #c4b5fd; }
.json-null { color: #94a3b8; }

.nav-item { transition: all 0.15s ease; }
.nav-item:hover { background: rgba(244, 204, 4, 0.08); }
.nav-item.active {
  background: rgba(244, 204, 4, 0.12);
  border-right: 3px solid #F4CC04;
  color: #F4CC04;
}

.spinner {
  border: 3px solid var(--td-card-border);
  border-top: 3px solid var(--td-accent);
  border-radius: 50%;
  width: 20px; height: 20px;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.typing-dot { animation: bounce 1.4s infinite ease-in-out both; }
.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }
@keyframes bounce { 0%, 80%, 100% { transform: scale(0); } 40% { transform: scale(1); } }

.card-hover { transition: all 0.2s ease; }
.card-hover:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.3); }

/* Recording indicator */
.recording-pulse {
  animation: recordPulse 1.5s ease-in-out infinite;
}
@keyframes recordPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.5); }
  50% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
}

.recording-wave {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 20px;
}
.recording-wave span {
  display: block;
  width: 3px;
  background: #ef4444;
  border-radius: 3px;
  animation: wave 1s ease-in-out infinite;
}
.recording-wave span:nth-child(1) { animation-delay: 0s; height: 8px; }
.recording-wave span:nth-child(2) { animation-delay: 0.1s; height: 14px; }
.recording-wave span:nth-child(3) { animation-delay: 0.2s; height: 10px; }
.recording-wave span:nth-child(4) { animation-delay: 0.3s; height: 18px; }
.recording-wave span:nth-child(5) { animation-delay: 0.4s; height: 12px; }
@keyframes wave {
  0%, 100% { transform: scaleY(0.5); }
  50% { transform: scaleY(1); }
}

.fade-out {
  transition: all 0.3s ease;
  opacity: 0;
  transform: translateX(50px);
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--td-accent) !important;
  box-shadow: 0 0 0 2px rgba(244, 204, 4, 0.15);
}

/* Audio seek slider */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: var(--td-input-border);
  border-radius: 2px;
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  background: var(--td-accent);
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.1s;
}
input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.3);
}
input[type="range"]::-moz-range-thumb {
  width: 12px;
  height: 12px;
  background: var(--td-accent);
  border-radius: 50%;
  border: none;
  cursor: pointer;
}

/* Chat audio player inline */
.audio-player-inline {
  display: flex;
  align-items: center;
  gap: 8px;
}
.audio-player-inline input[type="range"] {
  flex: 1;
  height: 3px;
}
.audio-player-inline button {
  flex-shrink: 0;
}

/* Markdown in chat bubbles */
.md-content { font-size: 0.875rem; line-height: 1.6; }
.md-content p { margin-bottom: 0.5rem; }
.md-content p:last-child { margin-bottom: 0; }
.md-content strong { color: #042D49; font-weight: 600; }
.md-content em { color: #33373D; font-style: italic; }
.md-content ul, .md-content ol { margin: 0.4rem 0; padding-left: 1.25rem; }
.md-content li { margin-bottom: 0.2rem; }
.md-content li::marker { color: #7A7A7A; }
.md-content ol { list-style-type: decimal; }
.md-content ul { list-style-type: disc; }
.md-content h1, .md-content h2, .md-content h3 {
  color: #042D49; font-weight: 600; margin: 0.75rem 0 0.35rem;
  font-family: 'Sora', sans-serif;
}
.md-content h1 { font-size: 1.1rem; }
.md-content h2 { font-size: 1rem; }
.md-content h3 { font-size: 0.9rem; }
.md-content h1:first-child, .md-content h2:first-child, .md-content h3:first-child { margin-top: 0; }
.md-content code {
  background: #e8edf2; color: #042D49; padding: 0.1rem 0.35rem;
  border-radius: 0.25rem; font-size: 0.8em;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
}
.md-content pre {
  background: #e8edf2; border: 1px solid #CED4DA; border-radius: 0.375rem;
  padding: 0.75rem; margin: 0.5rem 0; overflow-x: auto;
}
.md-content pre code {
  background: none; padding: 0; font-size: 0.78rem;
}
.md-content blockquote {
  border-left: 3px solid #F4CC04; padding-left: 0.75rem;
  margin: 0.5rem 0; color: #54595F;
}
.md-content table {
  width: 100%; border-collapse: collapse; margin: 0.5rem 0; font-size: 0.8rem;
}
.md-content th {
  background: #e8edf2; padding: 0.35rem 0.5rem; text-align: left;
  border: 1px solid #CED4DA; font-weight: 600; color: #042D49;
}
.md-content td {
  padding: 0.3rem 0.5rem; border: 1px solid #CED4DA; color: #33373D;
}
.md-content tr:nth-child(even) { background: #f8f9fa; }
.md-content hr { border: none; border-top: 1px solid #CED4DA; margin: 0.75rem 0; }
.md-content a { color: #042D49; text-decoration: underline; }
.md-content a:hover { color: #F4CC04; }

/* Yellow accent stripe (decorative) */
.td-stripe {
  height: 4px;
  background: var(--td-accent);
}

/* ===== Sidebar collapse/expand ===== */
#sidebar {
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}
#sidebar.collapsed { width: 4rem; }
#sidebar.collapsed .sidebar-text {
  opacity: 0;
  width: 0;
  overflow: hidden;
  white-space: nowrap;
  transition: opacity 0.15s ease;
}
#sidebar.collapsed .sidebar-logo {
  display: none;
}
#sidebar.collapsed .sidebar-header {
  justify-content: center;
}
#sidebar.collapsed .sidebar-footer {
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}
#sidebar.collapsed #btn-profile {
  justify-content: center;
}
#sidebar.collapsed #btn-logout {
  position: static;
}
#sidebar:not(.collapsed) .sidebar-text {
  opacity: 1;
  transition: opacity 0.2s ease 0.1s;
}
#sidebar.collapsed .nav-item {
  justify-content: center;
  padding-left: 0;
  padding-right: 0;
}
#sidebar.collapsed .session-item {
  justify-content: center;
  padding-left: 0.5rem;
  padding-right: 0.5rem;
}

/* ===== Session list items ===== */
.session-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.75rem;
  border-radius: 0.5rem;
  cursor: pointer;
  transition: all 0.15s ease;
  color: #94a3b8;
  position: relative;
}
.session-item:hover { background: rgba(244, 204, 4, 0.06); color: #cbd5e1; }
.session-item.active {
  background: rgba(244, 204, 4, 0.12);
  color: #F4CC04;
}

/* Session action buttons (visible on hover) */
.session-actions {
  display: none;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}
.session-item:hover .session-actions { display: flex; }
.session-actions button {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  color: #64748b;
  transition: all 0.15s ease;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
}
.session-actions button:hover { color: #F4CC04; background: rgba(244, 204, 4, 0.1); }
.session-actions .btn-session-delete:hover { color: #f87171; background: rgba(248, 113, 113, 0.1); }

/* Sidebar collapsed: hide session actions */
#sidebar.collapsed .session-actions { display: none !important; }

/* Session select mode */
.session-checkbox {
  width: 14px;
  height: 14px;
  accent-color: #F4CC04;
  cursor: pointer;
  flex-shrink: 0;
}
.session-item.selected {
  background: rgba(244, 204, 4, 0.08);
  border: 1px solid rgba(244, 204, 4, 0.2);
}
.bulk-action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 0.75rem;
  background: rgba(248, 113, 113, 0.08);
  border: 1px solid rgba(248, 113, 113, 0.2);
  border-radius: 0.5rem;
  margin-bottom: 0.25rem;
}

/* ===== Profile modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-content {
  background: var(--td-card);
  border: 1px solid var(--td-card-border);
  border-radius: 1rem;
  padding: 2rem;
  max-width: 28rem;
  width: 90%;
  animation: modalSlideIn 0.3s ease;
}
@keyframes modalSlideIn {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
