/**
 * DocForge — Custom styles
 * Only non-DaisyUI utilities live here. All components use DaisyUI classes.
 */

/* ── Tab icons (15px inline SVG via mask) ── */

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

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

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

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

.animate-spin  { animation: spin 1s linear infinite; }
.animate-pulse { animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite; }
.fade-in       { animation: fadeIn 0.3s ease-out; }
.tab-fade-in   { animation: tabFadeIn 0.2s ease-out; }

/* ── Scrollbar ── */

::-webkit-scrollbar        { width: 6px; height: 6px; }
::-webkit-scrollbar-track  { background: oklch(var(--b2)); }
::-webkit-scrollbar-thumb  { background: oklch(var(--bc) / 0.2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: oklch(var(--bc) / 0.35); }

/* ── Focus ring ── */

.focus-ring:focus,
.focus-ring:focus-visible {
  outline: 2px solid oklch(var(--p));
  outline-offset: 2px;
}

/* ── Chart container ── */

.chart-container {
  position: relative;
  height: 300px;
  width: 100%;
}
.chart-container canvas { max-height: 100%; }

/* ── Loading overlay ── */

.loading-overlay {
  position: fixed; inset: 0;
  background-color: oklch(var(--b1) / 0.8);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
}

.loading-spinner {
  display: flex; align-items: center; gap: 0.5rem;
  background: oklch(var(--b1));
  padding: 1rem 1.5rem;
  border-radius: var(--radius, 0.375rem);
  box-shadow: 0 4px 12px oklch(0 0 0 / 0.1);
}

/* ── Icons (background-image from /static/img/) ── */

.tab-icon, .icon, .icon-sm, .icon-xs {
  display: inline-block;
  background-repeat: no-repeat;
  background-size: contain;
  background-position: center;
  flex-shrink: 0;
}

.tab-icon, .icon { width: 15px; height: 15px; margin-right: 3px; vertical-align: -2px; }
.icon-sm { width: 13px; height: 13px; margin-right: 2px; vertical-align: -1px; }
.icon-xs { width: 11px; height: 11px; margin-right: 2px; vertical-align: -1px; }

/* ── Tab bar ── */
.svg-upload   { background-image: url("/static/img/ingest.svg"); }
.svg-archive  { background-image: url("/static/img/archive.svg"); }
.svg-extract  { background-image: url("/static/img/extract.svg"); }
.svg-query    { background-image: url("/static/img/query.svg"); }
.svg-schema   { background-image: url("/static/img/schema.svg"); }
.svg-config   { background-image: url("/static/img/config.svg"); }
.svg-llm      { background-image: url("/static/img/llm-config.svg"); }
.svg-keys     { background-image: url("/static/img/key.svg"); }

/* ── Config sections ── */
.svg-general   { background-image: url("/static/img/general.svg"); }
.svg-models    { background-image: url("/static/img/models.svg"); }
.svg-vision    { background-image: url("/static/img/vision.svg"); }
.svg-docindex  { background-image: url("/static/img/docindex.svg"); }
.svg-security  { background-image: url("/static/img/security.svg"); }

/* ── Sidebar ── */
.svg-workspace { background-image: url("/static/img/workspace.svg"); }
.svg-files     { background-image: url("/static/img/files.svg"); }

/* ── Actions ── */
.svg-save    { background-image: url("/static/img/save.svg"); }
.svg-play    { background-image: url("/static/img/play.svg"); }
.svg-stop    { background-image: url("/static/img/stop.svg"); }
.svg-send    { background-image: url("/static/img/send.svg"); }
.svg-cleanup { background-image: url("/static/img/cleanup.svg"); }
.svg-select  { background-image: url("/static/img/select.svg"); }
.svg-refresh { background-image: url("/static/img/refresh.svg"); }

/* ── Tab styling ── */
/* Self-contained. No DaisyUI .tab class — avoids framework overrides. */

button.ui-tab-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  font-size: 0.8rem;
  padding: 0.35rem 0.75rem;
  font-weight: 500;
  color: oklch(var(--bc) / 0.5);
  background-color: transparent;
  border: none;
  border-radius: 0;
  outline: none !important;
  box-shadow: none !important;
  cursor: pointer;
  transition: color 0.15s ease, background-color 0.15s ease;
}

button.ui-tab-btn:hover {
  color: oklch(var(--pc));
  background-color: oklch(var(--p) / 0.15);
}

button.ui-tab-btn:active {
  background-color: oklch(var(--p) / 0.25);
}

button.ui-tab-btn.tab-active,
button.ui-tab-btn[aria-selected="true"] {
  font-weight: 600;
  color: oklch(var(--pc));
  background-color: oklch(var(--p));
}

button.ui-tab-btn:focus,
button.ui-tab-btn:focus-visible {
  outline: none !important;
  box-shadow: none !important;
}

/* ── Print ── */

@media print {
  .no-print { display: none !important; }
  .card { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
  .modal { position: static; box-shadow: none; max-width: 100%; }
}

/* ── Reduced motion ── */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ── Config dirty highlight ── */

.config-dirty {
  border-color: oklch(var(--p)) !important;
  box-shadow: 0 0 0 1px oklch(var(--p) / 0.3);
}

/* ── Card hover lift ── */

.card-lift {
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.card-lift:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px oklch(0 0 0 / 0.08);
}

/* ── Dark mode brand glow ── */

[data-theme="business"] .brand-text,
[data-theme="night"]    .brand-text,
[data-theme="dim"]      .brand-text,
[data-theme="black"]    .brand-text,
[data-theme="dracula"]  .brand-text,
[data-theme="sunset"]   .brand-text {
  text-shadow: 0 0 12px oklch(var(--p) / 0.3);
}

/* ── File viewer code block ── */
#file-view-code {
  line-height: 1.5;
  max-height: 70vh;
  overflow: auto;
  border-radius: 0.375rem;
  padding: 0.75rem;
  margin: 0;
  background: oklch(var(--b2)) !important;
  color: oklch(var(--bc));
}
#file-view-code code {
  background: none !important;
  padding: 0 !important;
}
/* Override hljs theme bg/color to follow DaisyUI tokens */
.hljs {
  background: transparent !important;
  color: inherit;
  padding: 0 !important;
}
