/* ── Override Bootstrap primary ─────────────────────────── */
:root {
  --bs-primary:     #2563eb;
  --bs-primary-rgb: 37, 99, 235;
  --header-h: 60px;
  --action-h: 64px;
  --app-surface: #fff;
  --app-bg: #f8f9fa;
  --app-muted-surface: #f8fafc;
  --app-shadow: rgba(15, 23, 42, .08);
}

[data-bs-theme="dark"] {
  --bs-primary: #60a5fa;
  --bs-primary-rgb: 96, 165, 250;
  --bs-body-bg: #101418;
  --bs-body-color: #e5e7eb;
  --bs-secondary-color: #a7b0bd;
  --bs-border-color: #303843;
  --app-surface: #171c22;
  --app-bg: #101418;
  --app-muted-surface: #202731;
  --app-shadow: rgba(0, 0, 0, .35);
}

.btn-primary {
  --bs-btn-bg:               #2563eb;
  --bs-btn-border-color:     #2563eb;
  --bs-btn-hover-bg:         #1d4ed8;
  --bs-btn-hover-border-color: #1d4ed8;
  --bs-btn-active-bg:        #1d4ed8;
  --bs-btn-focus-shadow-rgb: 37, 99, 235;
}
.btn-outline-primary {
  --bs-btn-color:         #2563eb;
  --bs-btn-border-color:  #2563eb;
  --bs-btn-hover-bg:      #2563eb;
  --bs-btn-active-bg:     #2563eb;
}
.btn-check:checked + .btn-outline-primary { background-color: #2563eb; border-color: #2563eb; }
.text-primary  { color: #2563eb !important; }
.bg-primary    { background-color: #2563eb !important; }
.alert-primary { --bs-alert-color: #1e3a8a; --bs-alert-bg: #eff6ff; --bs-alert-border-color: #bfdbfe; }
.progress-bar  { background-color: #2563eb; }
.form-check-input:checked { background-color: #2563eb; border-color: #2563eb; }

[data-bs-theme="dark"] .btn-primary {
  --bs-btn-bg: #3b82f6;
  --bs-btn-border-color: #3b82f6;
  --bs-btn-hover-bg: #60a5fa;
  --bs-btn-hover-border-color: #60a5fa;
  --bs-btn-active-bg: #2563eb;
  --bs-btn-focus-shadow-rgb: 96, 165, 250;
}
[data-bs-theme="dark"] .btn-outline-primary {
  --bs-btn-color: #8ec5ff;
  --bs-btn-border-color: #3b82f6;
  --bs-btn-hover-bg: #2563eb;
  --bs-btn-active-bg: #2563eb;
}
[data-bs-theme="dark"] .btn-check:checked + .btn-outline-primary { background-color: #2563eb; border-color: #3b82f6; }
[data-bs-theme="dark"] .text-primary { color: #8ec5ff !important; }
[data-bs-theme="dark"] .bg-primary { background-color: #2563eb !important; }
[data-bs-theme="dark"] .alert-primary {
  --bs-alert-color: #bfdbfe;
  --bs-alert-bg: #17233a;
  --bs-alert-border-color: #28456f;
}

.app-body { background: var(--app-bg); }

/* ── Header ─────────────────────────────────────────────── */
.app-header {
  height: var(--header-h);
  background: var(--app-surface);
  border-bottom: 1px solid var(--bs-border-color);
  display: flex;
  align-items: center;
  padding: 0 1.25rem;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 1030;
}
.header-brand  { display: flex; align-items: center; gap: .6rem; flex: 1; }
.header-title  { font-weight: 600; font-size: 1rem; line-height: 1.2; }
.header-logo   {
  width: 34px; height: 34px;
  background: #2563eb; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-size: 1.1rem; flex-shrink: 0;
}
.header-nav    { display: flex; height: 100%; }
.nav-tab {
  display: flex; align-items: center; gap: .35rem;
  padding: 0 1rem; height: 100%;
  font-size: .875rem; color: var(--bs-secondary-color);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  transition: color .15s, border-color .15s;
}
.nav-tab:hover { color: var(--bs-body-color); }
.nav-tab.active { color: #2563eb; border-bottom-color: #2563eb; font-weight: 500; }

/* ── Mobile nav ─────────────────────────────────────────── */
.mobile-nav { background: var(--app-surface); border-bottom: 1px solid var(--bs-border-color); }
.mobile-nav-item {
  display: flex; align-items: center; gap: .5rem;
  padding: .7rem 1.25rem; font-size: .9rem;
  color: var(--bs-secondary-color); text-decoration: none;
}
.mobile-nav-item.active { color: #2563eb; font-weight: 500; }

/* ── User avatar ─────────────────────────────────────────── */
.user-avatar {
  width: 34px; height: 34px;
  background: #2563eb; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-size: .75rem; font-weight: 700; flex-shrink: 0;
}
.theme-toggle {
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
}

/* ── Sticky query card ───────────────────────────────────── */
.sticky-query {
  position: sticky;
  top: var(--header-h);
  z-index: 10;
  background: #dbeafe;
  border-color: #93c5fd !important;
  border-left: 4px solid #2563eb !important;
}
[data-bs-theme="dark"] .sticky-query {
  background: #1a2744;
  border-color: #1e3a6e !important;
  border-left: 4px solid #60a5fa !important;
}
@media (min-width: 992px) {
  .sticky-query { top: 0; }
}

/* ── Task 3-column layout ────────────────────────────────── */
.app-main { min-height: calc(100vh - var(--header-h)); }

.task-layout {
  display: grid;
  grid-template-columns: 240px 1fr 300px;
  height: calc(100vh - var(--header-h) - var(--action-h));
  overflow: hidden;
}
@media (max-width: 991px) {
  .task-layout {
    display: block;
    height: auto;
    overflow: visible;
  }
}

.sidebar      { background: var(--app-surface); border-right: 1px solid var(--bs-border-color); padding: 1.25rem; overflow-y: auto; }
.main-content { padding: 1.25rem; }
.right-panel  { background: var(--app-surface); border-left:  1px solid var(--bs-border-color); padding: 1.25rem; overflow-y: auto; }
@media (min-width: 992px) {
  .main-content { overflow-y: auto; }
}

/* ── Sidebar ─────────────────────────────────────────────── */
.progress-counter { font-size: 1.15rem; font-weight: 700; }

/* ── Passage number circle ───────────────────────────────── */
.passage-number {
  width: 28px; height: 28px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .75rem; font-weight: 700;
}
.passage-text {
  font-size: .98rem;
  line-height: 1.65;
}

/* ── Action bar ─────────────────────────────────────────── */
.action-bar {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: var(--action-h);
  background: var(--app-surface);
  border-top: 1px solid var(--bs-border-color);
  display: flex; align-items: center;
  padding: 0 1.25rem; gap: 1rem;
  z-index: 1020;
}
.action-bar-right { margin-left: auto; display: flex; gap: .5rem; }
.min-w-0 { min-width: 0; }

/* ── Login ───────────────────────────────────────────────── */
.login-logo    { width: 48px; height: 48px; font-size: 1.5rem; border-radius: 12px; }
.login-title   { font-size: 1.05rem; font-weight: 700; line-height: 1.35; }
.login-password-wrap { position: relative; }
.password-toggle {
  position: absolute; right: .6rem; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer;
  color: var(--bs-secondary-color); font-size: 1rem; padding: .25rem; z-index: 5;
}
.login-lang-switcher { display: flex; justify-content: flex-end; margin-bottom: 1.25rem; }
.login-lang-switcher select { width: auto; font-size: .8rem; }

[data-bs-theme="dark"] .card,
[data-bs-theme="dark"] .dropdown-menu,
[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select {
  box-shadow: 0 1px 2px var(--app-shadow);
}

[data-bs-theme="dark"] .bg-light {
  background-color: var(--app-muted-surface) !important;
}

[data-bs-theme="dark"] .text-dark {
  color: var(--bs-body-color) !important;
}

[data-bs-theme="dark"] .btn-outline-secondary {
  --bs-btn-color: #c5ccd6;
  --bs-btn-border-color: #4b5563;
  --bs-btn-hover-bg: #2f3742;
  --bs-btn-hover-border-color: #667085;
  --bs-btn-active-bg: #2f3742;
  --bs-btn-active-border-color: #667085;
}
