/* ============================================================
   LIMS3 Refurb — Global visual polish
   ============================================================ */


/* ── 1. ENVIRONMENT BANNERS ─────────────────────────────────── */

.dev-env-banner,
.staging-env-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 24px;
  z-index: 1050;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4em;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.18);
}

.dev-env-banner     { background: linear-gradient(90deg, #2196F3, #1565C0); }
.staging-env-banner { background: linear-gradient(90deg, #ff9800, #f57c00); }

/* Mobile (<576px): collapse to corner pill so it doesn't eat content */
@media (max-width: 575.98px) {
  .dev-env-banner,
  .staging-env-banner {
    top: 8px;
    right: 8px;
    left: auto;
    width: auto;
    height: auto;
    padding: 3px 8px;
    border-radius: 100px;
    font-size: 8px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.25);
  }
  .dev-env-banner i,
  .staging-env-banner i { display: none; }
}


/* ── 1b. LIST TOOLBAR ────────────────────────────────────────── */

.lims3-list-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0;
  margin-bottom: 1rem;
  position: sticky;
  top: 24px;       /* clears the 24px dev/staging banner */
  z-index: 10;
  background: var(--bs-body-bg, #1a1a1a);
  border-bottom: 1px solid #f1f3f5;
}

body.light-theme .lims3-list-toolbar {
  background: #f8f9fa;
  border-bottom-color: #dee2e6;
}

body:not(.light-theme) .lims3-list-toolbar {
  border-bottom-color: #404040;
}

@media (max-width: 575.98px) {
  .lims3-list-toolbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
    /* Fix: clear the 56px .navbar-mobile so sticky toolbar isn't hidden under it */
    top: 56px;
  }
}

@media (min-width: 576px) and (max-width: 991.98px) {
  /* Fix: tablet/medium also has .navbar-mobile (shown <992px) — sticky must clear it */
  .lims3-list-toolbar {
    top: 56px;
  }
}


/* ── 2. PAGE HEADERS ─────────────────────────────────────────── */

/*
 * Limitless theme sets --page-header-padding-y: 1.5rem and applies it as
 * padding on .page-title. The <style> block in navbar.ejs (loaded after this
 * file) sets background-color: #2d2d2d on .page-header. All overrides here
 * must use !important to win.
 */
.page-header {
  --page-header-padding-y: 0;
  padding: 0 !important;
  margin-bottom: 0 !important;
  border-bottom: none !important;
  background: transparent !important;
}

.page-header-content {
  padding-left: 0 !important;
  padding-right: 0 !important;
}

.page-title {
  /* reset theme's 1.5rem top/bottom padding, set our own */
  padding: 0 0 0.625rem 0.875rem !important;
  margin-bottom: 1rem !important;   /* override mb-0 Bootstrap utility */
  font-size: 1.25rem !important;
  font-weight: 700 !important;
  color: #111 !important;
  position: relative;
  border-bottom: 1px solid #f1f3f5;
  display: flex !important;
  align-items: baseline;
  gap: 0.4em;
}

/* Accent bar */
.page-title::before {
  content: '';
  position: absolute;
  left: 0;
  top: 2px;
  width: 3px;
  height: 20px;
  background: #2563eb;
  border-radius: 2px;
}

/* Subtitle / suffix word */
.page-title .fw-normal {
  font-weight: 400 !important;
  color: #6b7280 !important;
}

/* Mobile compaction */
@media (max-width: 991.98px) {
  .page-title {
    font-size: 1.1rem !important;
    padding: 0 0 0.5rem 0.75rem !important;
    margin-bottom: 0.75rem !important;
  }
  .page-title::before {
    height: 16px;
  }
}

/* Dark-theme adjustments */
body:not(.light-theme) .page-title {
  color: #e8e8e8 !important;
  border-bottom-color: rgba(255,255,255,0.08);
}
body:not(.light-theme) .page-title::before {
  background: #60a5fa;
}
body:not(.light-theme) .page-title .fw-normal {
  color: #9ca3af !important;
}


/* ── 2b. SIDEBAR BOTTOM ──────────────────────────────────────── */

.sidebar-bottom {
  border-top: 1px solid rgba(255,255,255,0.08) !important;
  padding-top: 0.625rem !important;
}

.sidebar-user-info-section {
  padding: 0.5rem 1rem 0.25rem !important;
}

.nav-sidebar-bottom .nav-link {
  font-size: 0.8125rem;
  padding-top: 0.375rem;
  padding-bottom: 0.375rem;
  opacity: 0.75;
}

.nav-sidebar-bottom .nav-link:hover {
  opacity: 1;
}


/* ── 2c. PAGE HEADER ROW (title + action buttons) ────────────── */

.lims3-page-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid #f1f3f5;
  margin-bottom: 0.875rem;
}

/* Suppress the title's own border/spacing — the row provides it */
.lims3-page-header-row .page-title {
  border-bottom: none !important;
  padding-bottom: 0 !important;
  margin-bottom: 0 !important;
}

.lims3-page-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

/* xs: actions go full-width below the title */
@media (max-width: 575.98px) {
  .lims3-page-actions {
    width: 100%;
  }
  .lims3-page-actions .btn {
    flex: 1;
    justify-content: center;
  }
}

body:not(.light-theme) .lims3-page-header-row {
  border-bottom-color: rgba(255,255,255,0.08);
}

body.light-theme .lims3-page-header-row {
  border-bottom-color: #dee2e6;
}


/* ── 2d. MOBILE CONTENT PADDING ──────────────────────────────── */

/* Reduce Limitless theme's 1.25rem top padding on mobile to recover dead space */
@media (max-width: 991.98px) {
  .content {
    padding-top: 0.75rem !important;
  }
}


/* ── 3. BUTTON CONSISTENCY ───────────────────────────────────── */

/* Danger → outline-only by default */
.btn-danger {
  background-color: transparent !important;
  color: #dc3545 !important;
  border-color: #dc3545 !important;
}
.btn-danger:hover,
.btn-danger:active,
.btn-danger:focus {
  background-color: #dc3545 !important;
  color: #fff !important;
  border-color: #dc3545 !important;
}

/* Escape hatch: .btn-danger.btn-danger-filled keeps the solid red style */
.btn-danger.btn-danger-filled {
  background-color: #dc3545 !important;
  color: #fff !important;
}
.btn-danger.btn-danger-filled:hover {
  background-color: #bb2d3b !important;
}

/* Mobile: enforce 44×44px minimum tap target */
@media (max-width: 991.98px) {
  .btn {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  /* Exempt icon-only toolbar buttons from the tall target */
  .btn.btn-sm.btn-icon,
  .btn.btn-xs {
    min-height: 32px;
  }
  /* Fix: 44px .btn was breaking input-group alignment on mobile —
     match the form-control height so input + button stay flush */
  .input-group .form-control,
  .input-group .form-select {
    min-height: 44px;
  }
}


/* ── 4. CARD POLISH ──────────────────────────────────────────── */

.card {
  border-radius: 8px !important;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04) !important;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.card:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.10) !important;
}

/* Suppress hover lift inside modals — too distracting */
.modal .card:hover {
  transform: none;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04) !important;
}

.card-header {
  background: #f8fafc !important;
  border-bottom: 1px solid #f1f3f5 !important;
  padding: 0.625rem 1rem !important;
  border-radius: 8px 8px 0 0 !important;
}

/* Dark-theme card adjustments */
body:not(.light-theme) .card-header {
  background: #262626 !important;
  border-bottom-color: #404040 !important;
}

/* Fix: card hover shadow rgba(0,0,0,0.10) was invisible on dark backgrounds —
   use a darker, more opaque shadow + subtle border highlight in dark mode */
body:not(.light-theme) .card:hover {
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45),
              0 0 0 1px rgba(255, 255, 255, 0.06) !important;
}


/* ── 5. STATUS BADGES ────────────────────────────────────────── */

.badge {
  border-radius: 100px !important;
}

/* Soft semantic colours — add these classes alongside .badge */
.badge-completed,
.badge-active {
  background-color: #dcfce7 !important;
  color: #15803d !important;
}

.badge-created,
.badge-pending {
  background-color: #dbeafe !important;
  color: #1d4ed8 !important;
}

.badge-draft,
.badge-warning {
  background-color: #fef9c3 !important;
  color: #854d0e !important;
}

.badge-error,
.badge-canceled {
  background-color: #fee2e2 !important;
  color: #b91c1c !important;
}


/* ── 6. MOBILE BOTTOM TAB BAR ────────────────────────────────── */

.lims3-bottom-nav {
  display: none; /* shown only on mobile via d-lg-none */
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: #1a1a1a;
  border-top: 1px solid #333;
  z-index: 1040;
  flex-direction: row;
  align-items: stretch;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* Bootstrap d-lg-none sets display:block; override to flex */
@media (max-width: 991.98px) {
  .lims3-bottom-nav {
    display: flex !important;
  }

  /* Push page content up so it isn't hidden behind the tab bar */
  .content-wrapper {
    padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px));
  }
}

.lims3-bottom-nav__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: #9ca3af;
  text-decoration: none;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.03em;
  transition: color 0.15s ease;
}

.lims3-bottom-nav__item i {
  font-size: 1.35rem;
  line-height: 1;
}

.lims3-bottom-nav__item:hover,
.lims3-bottom-nav__item.active {
  color: #60a5fa;
}

/* Light theme */
body.light-theme .lims3-bottom-nav {
  background: #ffffff;
  border-top-color: #e5e7eb;
}

body.light-theme .lims3-bottom-nav__item {
  color: #6b7280;
}

body.light-theme .lims3-bottom-nav__item:hover,
body.light-theme .lims3-bottom-nav__item.active {
  color: #2563eb;
}

/* Button reset for .lims3-mehr-btn inside the tab bar */
.lims3-mehr-btn {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}


/* ── 7. MEHR OVERLAY ─────────────────────────────────────────── */

.lims3-mehr-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--bs-body-bg, #fff);
  z-index: 1045;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.lims3-mehr-overlay.open {
  display: flex;
}

.lims3-mehr-overlay__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  padding-top: calc(1rem + env(safe-area-inset-top, 0px));
  border-bottom: 1px solid #f1f3f5;
}

.lims3-mehr-overlay__title {
  font-size: 1rem;
  font-weight: 600;
  color: #111;
}

.lims3-mehr-overlay__close {
  background: none;
  border: none;
  font-size: 22px;
  color: #6b7280;
  padding: 4px;
  cursor: pointer;
  line-height: 1;
}

.lims3-mehr-overlay__nav {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0;
}

.lims3-mehr-overlay__item {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 0.875rem 1.25rem;
  text-decoration: none;
  color: #374151;
  font-size: 0.9375rem;
  font-weight: 500;
  border-bottom: 1px solid #f9fafb;
  transition: background 0.1s;
}

.lims3-mehr-overlay__item i {
  font-size: 20px;
  color: #6b7280;
}

.lims3-mehr-overlay__item.active {
  color: #2563eb;
  background: #eff6ff;
}

.lims3-mehr-overlay__item.active i {
  color: #2563eb;
}

.lims3-mehr-overlay__item:hover:not(.active) {
  background: #f9fafb;
}

/* Dark mode */
body:not(.light-theme) .lims3-mehr-overlay {
  background: #1a1a1a;
}

body:not(.light-theme) .lims3-mehr-overlay__header {
  border-bottom-color: #333;
}

body:not(.light-theme) .lims3-mehr-overlay__title {
  color: #f9fafb;
}

body:not(.light-theme) .lims3-mehr-overlay__close {
  color: #9ca3af;
}

body:not(.light-theme) .lims3-mehr-overlay__item {
  color: #d1d5db;
  border-bottom-color: #2a2a2a;
}

body:not(.light-theme) .lims3-mehr-overlay__item i {
  color: #9ca3af;
}

body:not(.light-theme) .lims3-mehr-overlay__item:hover:not(.active) {
  background: #252525;
}

body:not(.light-theme) .lims3-mehr-overlay__item.active {
  color: #60a5fa;
  background: #1e2d3d;
}

body:not(.light-theme) .lims3-mehr-overlay__item.active i {
  color: #60a5fa;
}


/* ── 8. FOCUS-VISIBLE (keyboard a11y) ────────────────────────── */
/* Fix: theme stripped/inconsistent focus rings — restore a clear keyboard
   focus indicator on interactive elements without affecting mouse users. */

.btn:focus-visible,
.lims3-bottom-nav__item:focus-visible,
.lims3-mehr-overlay__item:focus-visible,
.lims3-mehr-overlay__close:focus-visible,
.lims3-mehr-btn:focus-visible,
.flash-toggle:focus-visible,
.nav-sidebar-bottom .nav-link:focus-visible,
a.lims3-bottom-nav__item:focus-visible {
  outline: 2px solid #60a5fa;
  outline-offset: 2px;
  box-shadow: none;
}

body.light-theme .btn:focus-visible,
body.light-theme .lims3-bottom-nav__item:focus-visible,
body.light-theme .lims3-mehr-overlay__item:focus-visible,
body.light-theme .lims3-mehr-overlay__close:focus-visible,
body.light-theme .lims3-mehr-btn:focus-visible,
body.light-theme .flash-toggle:focus-visible,
body.light-theme .nav-sidebar-bottom .nav-link:focus-visible {
  outline-color: #2563eb;
}


/* ── 9. SETTINGS TABLE DARK MODE ─────────────────────────────── */

[data-bs-theme="dark"] .settings-table,
[data-bs-theme="dark"] .settings-table td,
[data-bs-theme="dark"] .settings-table th,
body:not(.light-theme) .settings-table,
body:not(.light-theme) .settings-table td,
body:not(.light-theme) .settings-table th {
  background-color: transparent;
}


/* ── 10. CONTENT BOTTOM PADDING ──────────────────────────────── */

.content-wrapper {
  padding-bottom: 1.5rem;
}


/* ── 11. NAV GROUPS ──────────────────────────────────────────── */

.nav-group-divider {
  list-style: none;
  height: 1px;
  background-color: var(--bs-border-color, #404040);
  opacity: 0.4;
  margin: 0.5rem 1rem;
  border: none;
  padding: 0;
}

.nav-group-label {
  list-style: none;
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--bs-secondary-color, #9ca3af);
  padding: 0.5rem 1rem 0.25rem;
  text-transform: uppercase;
}

[data-bs-theme="dark"] .nav-group-divider,
body:not(.light-theme) .nav-group-divider {
  opacity: 0.25;
}

/* Mobile offcanvas: hide group structure to keep drawer minimal */
@media (max-width: 991.98px) {
  #sidebarOffcanvas .nav-group-divider,
  #sidebarOffcanvas .nav-group-label {
    display: none;
  }
}
