:root {
  --dq-primary: #0d9f6e;
  --dq-primary-dark: #087a54;
  --dq-primary-light: #e6f7f0;
  --dq-accent: #2563eb;
  --dq-accent-hover: #1d4ed8;
  --dq-surface: #f8fafb;
  --dq-card: #ffffff;
  --dq-card-border: #e5e7eb;
  --dq-input: #f3f4f6;
  --dq-input-border: #d1d5db;
  --dq-muted: #6b7280;
  --dq-text: #111827;
  --dq-sidebar: #0d9f6e;
  --dq-sidebar-dark: #065f46;
}

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

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--dq-surface);
}
::-webkit-scrollbar-thumb {
  background: var(--dq-input-border);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--dq-muted);
}

.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(--dq-input);
  border: 1px solid var(--dq-card-border);
  border-radius: 0.75rem;
  padding: 1rem;
  font-family: "JetBrains Mono", "Fira Code", monospace;
  font-size: 0.75rem;
  color: #374151;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 400px;
  overflow-y: auto;
}
.json-key {
  color: #374151;
  font-weight: 600;
}
.json-string {
  color: #4b5563;
}
.json-number {
  color: #1f2937;
}
.json-boolean {
  color: #1f2937;
}
.json-null {
  color: #6b7280;
}

.nav-item {
  transition: all 0.15s ease;
}
.nav-item:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}
.nav-item.active {
  background: rgba(255, 255, 255, 0.2);
  border-right: 3px solid #fff;
  color: #fff;
  font-weight: 600;
}

/* Nav groups */
.nav-group-toggle:hover {
  background: rgba(255, 255, 255, 0.08);
}
.nav-group-items {
  transition: all 0.2s ease;
}
.nav-group.open > .nav-group-toggle .nav-group-chevron {
  transform: rotate(0deg);
}
.nav-group:not(.open) > .nav-group-toggle .nav-group-chevron {
  transform: rotate(-90deg);
}

.spinner {
  border: 3px solid var(--dq-card-border);
  border-top: 3px solid var(--dq-primary);
  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(--dq-primary) !important;
  box-shadow: 0 0 0 2px rgba(13, 159, 110, 0.15);
}

/* Audio seek slider */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: var(--dq-input-border);
  border-radius: 2px;
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  background: var(--dq-primary);
  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(--dq-primary);
  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: #111827;
  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: #111827;
  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: #f3f4f6;
  color: #111827;
  padding: 0.1rem 0.35rem;
  border-radius: 0.25rem;
  font-size: 0.8em;
  font-family: "JetBrains Mono", "Fira Code", monospace;
}
.md-content pre {
  background: #f3f4f6;
  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 var(--dq-primary);
  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: #f3f4f6;
  padding: 0.35rem 0.5rem;
  text-align: left;
  border: 1px solid #ced4da;
  font-weight: 600;
  color: #111827;
}
.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: #0d9f6e;
  text-decoration: underline;
}
.md-content a:hover {
  color: #087a54;
}

/* ===== KB Markdown (dark theme) ===== */
.kb-markdown {
  font-size: 0.8rem;
  line-height: 1.65;
  color: #cbd5e1;
  word-break: break-word;
}
.kb-markdown p {
  margin-bottom: 0.45rem;
}
.kb-markdown p:last-child {
  margin-bottom: 0;
}
.kb-markdown strong {
  color: #e2e8f0;
  font-weight: 600;
}
.kb-markdown em {
  color: #94a3b8;
  font-style: italic;
}
.kb-markdown ul,
.kb-markdown ol {
  margin: 0.35rem 0;
  padding-left: 1.25rem;
}
.kb-markdown li {
  margin-bottom: 0.15rem;
}
.kb-markdown li::marker {
  color: #64748b;
}
.kb-markdown ol {
  list-style-type: decimal;
}
.kb-markdown ul {
  list-style-type: disc;
}
.kb-markdown h1,
.kb-markdown h2,
.kb-markdown h3,
.kb-markdown h4 {
  color: #f1f5f9;
  font-weight: 600;
  margin: 0.6rem 0 0.3rem;
  font-family: "Sora", sans-serif;
}
.kb-markdown h1 {
  font-size: 1rem;
  border-bottom: 1px solid var(--dq-card-border);
  padding-bottom: 0.25rem;
}
.kb-markdown h2 {
  font-size: 0.9rem;
}
.kb-markdown h3 {
  font-size: 0.85rem;
  color: #e2e8f0;
}
.kb-markdown h4 {
  font-size: 0.8rem;
  color: #cbd5e1;
}
.kb-markdown h1:first-child,
.kb-markdown h2:first-child,
.kb-markdown h3:first-child {
  margin-top: 0;
}
.kb-markdown code {
  background: rgba(30, 58, 95, 0.6);
  color: #93c5fd;
  padding: 0.1rem 0.35rem;
  border-radius: 0.25rem;
  font-size: 0.78em;
  font-family: "JetBrains Mono", "Fira Code", monospace;
}
.kb-markdown pre {
  background: var(--dq-primary-dark);
  border: 1px solid var(--dq-card-border);
  border-radius: 0.5rem;
  padding: 0.75rem;
  margin: 0.5rem 0;
  overflow-x: auto;
}
.kb-markdown pre code {
  background: none;
  padding: 0;
  color: #e2e8f0;
  font-size: 0.75rem;
}
.kb-markdown blockquote {
  border-left: 3px solid var(--dq-primary);
  padding-left: 0.75rem;
  margin: 0.5rem 0;
  color: #94a3b8;
  background: rgba(13, 159, 110, 0.03);
  padding: 0.5rem 0.75rem;
  border-radius: 0 0.25rem 0.25rem 0;
}
.kb-markdown table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.5rem 0;
  font-size: 0.75rem;
}
.kb-markdown th {
  background: var(--dq-card);
  padding: 0.4rem 0.6rem;
  text-align: left;
  border: 1px solid var(--dq-card-border);
  font-weight: 600;
  color: #e2e8f0;
}
.kb-markdown td {
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--dq-card-border);
  color: #94a3b8;
}
.kb-markdown tr:nth-child(even) {
  background: rgba(13, 33, 55, 0.5);
}
.kb-markdown hr {
  border: none;
  border-top: 1px solid var(--dq-card-border);
  margin: 0.6rem 0;
}
.kb-markdown a {
  color: #93c5fd;
  text-decoration: underline;
}
.kb-markdown a:hover {
  color: var(--dq-primary);
}
.kb-markdown img {
  max-width: 100%;
  border-radius: 0.5rem;
  margin: 0.5rem 0;
}

/* Green accent stripe (decorative) */
.dq-stripe {
  height: 4px;
  background: var(--dq-primary);
}

/* ===== 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;
  gap: 0;
}
#sidebar.collapsed .nav-item.active {
  border-right: none;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.109);
}
#sidebar.collapsed .nav-group-items {
  padding-left: 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: rgba(255, 255, 255, 0.6);
  position: relative;
}
.session-item:hover {
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.9);
}
.session-item.active {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

/* 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: #0d9f6e;
  background: rgba(13, 159, 110, 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: #0d9f6e;
  cursor: pointer;
  flex-shrink: 0;
}
.session-item.selected {
  background: rgba(13, 159, 110, 0.08);
  border: 1px solid rgba(13, 159, 110, 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(--dq-card);
  border: 1px solid var(--dq-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;
  }
}

/* ===== Custom Cursors =====
   Design: white fill, #0D9F6E stroke 1.5, #111827 accents
   Sizes: all ~20-22px canvas for visual consistency
*/

/* Default arrow (20x22) — white body, dark outline, green accent */
html {
  cursor:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='22' fill='none'%3E%3Cpath d='M3,1 L3,17 L7,13 L10,19 L12.5,17.5 L9.5,12 L15,12 Z' fill='white' stroke='%23111827' stroke-width='1.5' stroke-linejoin='round'/%3E%3Cpath d='M3,1 L3,6' stroke='%230D9F6E' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E")
      3 1,
    default;
}

/* Pointer — native cursor for interactive elements */
a,
button,
[role="button"],
label[for],
select,
summary,
[onclick],
.nav-item,
.session-item,
.card-hover,
input[type="checkbox"],
input[type="radio"],
input[type="file"],
input[type="range"],
.session-actions button,
.cursor-pointer {
  cursor:
    pointer;
}

/* Restore native text cursor for inputs */
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not(
    [type="range"]
  ):not([type="button"]):not([type="submit"]),
textarea {
  cursor: text;
}

/* Grab hand (22x22) — three fingers + rounded palm */
.cursor-grab {
  cursor:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' fill='none'%3E%3Crect x='2.5' y='10.5' width='16' height='10' rx='4' fill='white' stroke='%230D9F6E' stroke-width='1.5'/%3E%3Cpath d='M4.5,11.5 V9 a2,2 0 0,1 4,0 v2.5' fill='white' stroke='%230D9F6E' stroke-width='1.5'/%3E%3Cpath d='M8.5,11.5 V6.5 a2,2 0 0,1 4,0 v5' fill='white' stroke='%230D9F6E' stroke-width='1.5'/%3E%3Cpath d='M12.5,11.5 V7 a2,2 0 0,1 4,0 v4.5' fill='white' stroke='%230D9F6E' stroke-width='1.5'/%3E%3C/svg%3E")
      11 4,
    grab;
}

/* Zoom-in magnifier (22x22) — circle with + sign */
.cursor-zoom-in {
  cursor:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' fill='none'%3E%3Ccircle cx='9' cy='9' r='7' fill='white' stroke='%230D9F6E' stroke-width='1.5'/%3E%3Cpath d='M9,6 v6 M6,9 h6' stroke='%230D9F6E' stroke-width='1.5' stroke-linecap='round'/%3E%3Cpath d='M14.5,14.5 L20,20' stroke='%23111827' stroke-width='2.5' stroke-linecap='round'/%3E%3C/svg%3E")
      9 9,
    zoom-in;
}

/* Zoom-out magnifier (22x22) — circle with - sign */
.cursor-zoom-out {
  cursor:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' fill='none'%3E%3Ccircle cx='9' cy='9' r='7' fill='white' stroke='%230D9F6E' stroke-width='1.5'/%3E%3Cpath d='M6,9 h6' stroke='%230D9F6E' stroke-width='1.5' stroke-linecap='round'/%3E%3Cpath d='M14.5,14.5 L20,20' stroke='%23111827' stroke-width='2.5' stroke-linecap='round'/%3E%3C/svg%3E")
      9 9,
    zoom-out;
}

/* Disabled / not-allowed */
button:disabled,
input:disabled,
select:disabled,
textarea:disabled,
.cursor-not-allowed {
  cursor: not-allowed !important;
}

/* Wait / loading */
.cursor-wait {
  cursor: wait !important;
}

/* ===== Stat Card Tooltips ===== */
.kb-stat-tooltip {
  transition:
    opacity 0.15s ease-out,
    visibility 0.15s ease-out,
    transform 0.15s ease-out;
  transform: translate(-50%, 4px);
}
.group:hover > .kb-stat-tooltip {
  transform: translate(-50%, 0);
}
