/* ═══════════════════════════════════════════════════════════════════════════
 * Check List PoC — Custom styles (Bootstrap 5 handles layout + components)
 * Only app-specific overrides and classes that JS depends on live here.
 * ═══════════════════════════════════════════════════════════════════════════ */

:root {
  --font-ui: "Inter", "Segoe UI", sans-serif;
}

body {
  font-family: var(--font-ui);
}

/* ── Sidebar (shared across pages) ──────────────────────────────────────── */

.sidebar-bs {
  font-family: var(--font-ui);
}

/* ── Admin panel visibility (JS toggles these) ──────────────────────────── */

.admin-panel {
  display: none;
}

.admin-panel-active {
  display: block;
}

/* ── Admin navigation (sidebar category tree) ───────────────────────────── */

.admin-nav-sub {
  display: none;
}

.admin-nav-cat.is-open > .admin-nav-sub {
  display: block;
}

.admin-nav-item.is-active {
  font-weight: 700;
  color: var(--bs-primary) !important;
  text-decoration: none;
}

/* ── Workspace views (JS toggling for user page) ────────────────────────── */

.workspace-view {
  display: none;
}

.workspace-view-active {
  display: block;
}

/* ── Toast notification ─────────────────────────────────────────────────── */

/* ── Desktop floating save bar (user task detail view, ≥md only) ─────────── */

.desktop-save-bar {
  display: none; /* hidden until JS adds .is-visible */
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 200;
  gap: 0.5rem;
  align-items: center;
}

.desktop-save-bar.is-visible {
  display: flex;
}

/* Never show the floating bar on mobile — mobile uses sidebar save buttons */
@media (max-width: 767.98px) {
  .desktop-save-bar.is-visible {
    display: none !important;
  }
}

.admin-toast {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9000;
  padding: 12px 20px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.88rem;
  opacity: 0;
  transform: translateY(-10px);
  pointer-events: none;
  transition: opacity 200ms ease, transform 200ms ease;
  background: #198754;
  color: #fff;
}

.admin-toast-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* ── Report list (index.html sidebar) ───────────────────────────────────── */

.report-list {
  display: grid;
  gap: 8px;
  max-height: 420px;
  overflow: auto;
}

.report-list-item {
  width: 100%;
  text-align: left;
  border: 1px solid rgba(0, 0, 0, 0.1);
  background: #fff;
  border-radius: 8px;
  padding: 10px 12px;
  display: grid;
  gap: 4px;
  cursor: pointer;
}

.report-list-item:hover {
  background: #f8f9fa;
}

.report-list-item.is-active,
.report-list-item--active {
  border-color: var(--bs-primary);
  background: rgba(13, 110, 253, 0.05);
}

.report-list-item__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.report-list-item__title {
  font-size: 0.9rem;
}

.report-list-item__meta {
  color: #6c757d;
  font-size: 0.8rem;
}

/* ── Task record cards (user page) ──────────────────────────────────────── */

.task-record-card {
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 12px;
}

.task-record-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.task-record-sort {
  font-weight: 700;
  font-size: 0.9rem;
  color: #fff;
}

.task-record-desc {
  flex: 1;
  font-size: 0.92rem;
}

.task-record-meta {
  font-size: 0.8rem;
  color: #6c757d;
}

.task-record-fields {
  margin-top: 8px;
}

.task-record-images {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-start;
}

.task-img-thumb {
  position: relative;
  display: inline-block;
}

.task-img-thumb img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid rgba(0, 0, 0, 0.1);
}

.task-img-thumb .btn-remove {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #fff;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  padding: 0;
  line-height: 20px;
  text-align: center;
  font-size: 0.8rem;
  border: 1px solid rgba(0, 0, 0, 0.15);
}

/* ── Admin list tables ──────────────────────────────────────────────────── */

/*
 * All admin CRUD list tables share the admin-table class. They are rendered
 * into containers that are already full-width, but without an explicit width
 * the browser collapses tables to their content width. Setting width:100%
 * stretches every table to the panel width. Striped rows and a light-bordered
 * header make the data easier to scan. The compact variant reduces cell
 * padding for tables with many columns (e.g. CL Records).
 */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.admin-table thead th {
  background: #f8f9fa;
  border-bottom: 2px solid #dee2e6;
  padding: 8px 12px;
  font-weight: 600;
  white-space: nowrap;
}

.admin-table tbody td {
  padding: 8px 12px;
  border-bottom: 1px solid #f0f0f0;
  vertical-align: middle;
}

.admin-table tbody tr:last-child td {
  border-bottom: none;
}

.admin-table tbody tr:hover td {
  background: #f8f9fa;
}

.admin-table-compact thead th {
  padding: 6px 8px;
}

.admin-table-compact tbody td {
  padding: 6px 8px;
}

.admin-table-actions {
  white-space: nowrap;
  text-align: right;
  width: 1%;        /* shrink-wrap — the remaining columns get all the space */
}

/* ── Drop zone (drag & drop images) ────────────────────────────────────── */

.drop-zone {
  cursor: pointer;
  transition: border-color 150ms ease, background-color 150ms ease;
}

.drop-zone:hover {
  border-color: var(--bs-primary) !important;
  background: rgba(13, 110, 253, 0.03);
}

/* ── Bulk image drop zone (smaller for inline use) ────────────────────── */

.bulk-drop-zone {
  cursor: pointer;
  transition: border-color 150ms ease, background-color 150ms ease;
  font-size: 0.8rem;
}

.bulk-drop-zone:hover {
  border-color: var(--bs-primary) !important;
  background: rgba(13, 110, 253, 0.05);
}

.bulk-img-thumb img {
  border: 1px solid #dee2e6;
}

/* ── Portal page ────────────────────────────────────────────────────────── */

.portal-body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
}

/* ── Connection badges (JS sets these classes) ──────────────────────────── */

.badge-online {
  background-color: #198754 !important;
  color: #fff !important;
}

.badge-offline {
  background-color: #ffc107 !important;
  color: #000 !important;
}

.badge-error {
  background-color: #dc3545 !important;
  color: #fff !important;
}

/* ── Sub-category group styling ─────────────────────────────────────────── */

.sub-cat-header {
  cursor: pointer;
  user-select: none;
}

.sub-cat-chevron {
  transition: transform 200ms ease;
}

.sub-cat-chevron.rotated {
  transform: rotate(90deg);
}

/* ── Category tabs (horizontal scroll / swipe on mobile) ───────────────── */

.tabs-scroll-wrapper {
  position: relative;
  display: flex;
  align-items: stretch;
}

/* Arrow buttons — hidden by default, shown only when there is overflow */
.tabs-scroll-arrow {
  display: none;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: 28px;
  background: #fff;
  border: 1px solid #dee2e6;
  border-bottom: none;
  cursor: pointer;
  z-index: 2;
  color: #495057;
  padding: 0;
  transition: background 0.15s;
}

.tabs-scroll-arrow:hover {
  background: #f8f9fa;
}

.tabs-scroll-arrow--left  { border-radius: 4px 0 0 0; }
.tabs-scroll-arrow--right { border-radius: 0 4px 0 0; }

/* Show arrows only when the list overflows */
.tabs-scroll-wrapper.has-overflow .tabs-scroll-arrow {
  display: flex;
}

/* Hide the arrow when already at that end */
.tabs-scroll-wrapper.at-start .tabs-scroll-arrow--left  { opacity: 0.3; pointer-events: none; }
.tabs-scroll-wrapper.at-end   .tabs-scroll-arrow--right { opacity: 0.3; pointer-events: none; }

#recordCategoryTabs {
  flex: 1;
  min-width: 0;
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

#recordCategoryTabs::-webkit-scrollbar {
  display: none;
}

/* ── Mobile hamburger button (hidden on desktop) ───────────────────────── */

.mobile-menu-btn {
  display: none;
  position: fixed;
  bottom: 16px;
  left: 16px;
  z-index: 1060;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

/* ── Responsive ─────────────────────────────────────────────────────────── */

/* Toggle button chevron rotation */
#toggleTaskInfoBtn .bi-chevron-up {
  transition: transform 200ms ease;
}
#taskInfoCollapse:not(.show) ~ .d-md-none #toggleTaskInfoBtn .bi-chevron-up,
.collapsed .bi-chevron-up {
  transform: rotate(180deg);
}

@media (max-width: 992px) {
  .sidebar-bs {
    width: 220px !important;
    min-width: 220px !important;
  }
}

@media (max-width: 768px) {
  .sidebar-bs {
    display: flex !important;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 260px !important;
    min-width: 260px !important;
    z-index: 1050;
    transform: translateX(-100%);
    transition: transform 250ms ease;
    box-shadow: none;
  }
  .sidebar-bs.sidebar-open {
    transform: translateX(0);
    box-shadow: 4px 0 16px rgba(0,0,0,0.15);
  }
  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1040;
    background: rgba(0,0,0,0.3);
  }
  .sidebar-backdrop.show {
    display: block;
  }
  .mobile-menu-btn {
    display: flex !important;
  }
}

/* ── Mobile task list cards ─────────────────────────────────────────────── */

.task-list-card {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(0,0,0,0.08);
  display: flex;
  align-items: center;
  gap: 12px;
}

.task-list-card:last-child {
  border-bottom: none;
}

.task-list-card-fields {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  align-items: center;
}

.task-list-field {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.task-list-field small {
  font-size: 0.7rem;
  color: #6c757d;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.task-list-field strong {
  font-size: 0.88rem;
}