/* ============================================================
   DashDigit app-specific styles layered on top of the shared theme
   (fonts.css, theme.css, components-theme.css, datatable-theme.css).
   Only things the shared theme doesn't already define live here.
   ============================================================ */

.navbar-app {
  background-color: var(--panel);
  border-bottom: 1px solid var(--border);
}

.text-muted-app {
  color: var(--muted) !important;
}

.app-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 1.1rem;
  color: var(--text);
}

.btn-accent {
  background-color: var(--blue);
  border-color: var(--blue);
  color: #fff;
}
.btn-accent:hover {
  filter: brightness(1.12);
  color: #fff;
}

/* Bootstrap's close-button X is black by default; invert it in dark mode so
   it's visible against our dark modal panels. Light mode keeps the default. */
[data-theme="dark"] .modal .btn-close {
  filter: invert(1) grayscale(100%) brightness(200%);
}

/* Bootstrap's form controls default to a light theme regardless of our
   data-theme attribute (Bootstrap only auto-themes via its own
   data-bs-theme). Re-point them at our palette. */
.modal .form-control,
.modal .form-select {
  background-color: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
}
.modal .form-control:focus,
.modal .form-select:focus {
  background-color: var(--panel-2);
  border-color: var(--blue);
  color: var(--text);
  box-shadow: 0 0 0 0.2rem var(--focus-ring);
}
.modal .form-label {
  color: var(--muted);
  font-size: 0.85rem;
}
.modal .form-control::placeholder {
  color: var(--muted);
}

.chat-bubble {
  border-radius: 1rem;
  padding: 0.75rem 1rem;
  margin-bottom: 0.75rem;
  max-width: 90%;
}
.chat-bubble.user {
  background: var(--tint-blue);
  border: 1px solid var(--border);
  margin-left: auto;
}
.chat-bubble.assistant {
  background: var(--panel);
  border: 1px solid var(--border);
}

.sql-block {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 0.6rem;
  padding: 0.5rem 0.75rem;
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
}

/* Prism SQL token colors, mapped onto this app's existing palette rather
   than importing a separate clashing Prism theme. */
.sql-block .token.keyword { color: var(--blue); font-weight: 600; }
.sql-block .token.function { color: var(--blue); }
.sql-block .token.string { color: #9ec97a; }
.sql-block .token.number { color: #d9a35c; }
.sql-block .token.operator,
.sql-block .token.punctuation { color: var(--muted); }
.sql-block .token.comment { color: var(--muted); font-style: italic; }

.widget-drag-handle {
  cursor: grab;
  color: var(--muted);
}

.sidebar-session {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  border-radius: 0.6rem;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  border: 1px solid transparent;
  color: var(--muted);
}
.sidebar-session:hover {
  background: var(--tint-blue);
  color: var(--text);
}
.sidebar-session.active {
  background: var(--blue);
  color: #fff;
}
.sidebar-session-title {
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-session-actions {
  display: flex;
  gap: 0.15rem;
  opacity: 0;
  flex-shrink: 0;
}
.sidebar-session:hover .sidebar-session-actions,
.sidebar-session:focus-within .sidebar-session-actions {
  opacity: 1;
}
.sidebar-session-actions button {
  background: none;
  border: none;
  color: inherit;
  padding: 0.1rem 0.3rem;
  line-height: 1;
  font-size: 0.85rem;
}
.sidebar-session-actions button:hover {
  filter: brightness(1.3);
}
.sidebar-session-rename-input {
  flex: 1 1 auto;
  min-width: 0;
}

/* Mobile: the chat-history sidebar becomes a slide-in overlay instead of a
   fixed column, so the chat area gets the full screen on a phone. */
@media (max-width: 767.98px) {
  #chat-sidebar {
    position: fixed;
    top: 56px;
    left: 0;
    bottom: 0;
    width: min(85vw, 320px);
    z-index: 1040;
    background: var(--bg);
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    overflow-y: auto;
  }
  #chat-sidebar.sidebar-open {
    transform: translateX(0);
  }
  #sidebar-backdrop.sidebar-open {
    display: block !important;
    position: fixed;
    top: 56px;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 1030;
  }
}
