/* ============================================================
   ASAP CMS — Main Stylesheet
   ============================================================ */

/* ---- Google Font ---- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
  --sidebar-width: 240px;
  --navbar-height: 56px;
  --primary: #0d6efd;
  --primary-dark: #0a58ca;
  --surface: #f8f9fa;
  --border: #dee2e6;
  --text: #212529;
  --text-muted: #6c757d;
  --sidebar-bg: #1a1d23;
  --sidebar-link: rgba(255,255,255,.72);
  --sidebar-link-hover: #fff;
  --sidebar-active-bg: rgba(13,110,253,.18);
}

/* ---- Global ---- */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: 'Inter', sans-serif;
  font-size: .9rem;
  background: var(--surface);
  color: var(--text);
  padding-top: var(--navbar-height);
  min-height: 100vh;
}

/* ---- Layout ---- */
.layout-wrapper {
  display: flex;
  min-height: calc(100vh - var(--navbar-height));
}

/* ---- Sidebar ---- */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  position: fixed;
  top: var(--navbar-height);
  left: 0;
  height: calc(100vh - var(--navbar-height));
  overflow-y: auto;
  z-index: 900;
  transition: transform .25s ease;
  box-shadow: 2px 0 16px rgba(0,0,0,.22);
}

.sidebar-inner { padding: .75rem .5rem 2rem; }

.sidebar-role-badge { padding: .25rem .5rem; }

.sidebar-nav .nav-link {
  color: var(--sidebar-link);
  border-radius: .5rem;
  padding: .5rem .85rem;
  font-size: .85rem;
  font-weight: 500;
  transition: background .15s, color .15s;
  display: flex;
  align-items: center;
}
.sidebar-nav .nav-link:hover {
  color: var(--sidebar-link-hover);
  background: rgba(255,255,255,.08);
}
.sidebar-nav .nav-link.active {
  color: #fff;
  background: var(--sidebar-active-bg);
  font-weight: 600;
}
.sidebar-nav .nav-link i { font-size: 1rem; }

/* Mobile sidebar overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 899;
}
.sidebar-overlay.show { display: block; }

/* Content area */
.content-area {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-width: 0;
  transition: margin-left .25s ease;
}

.content-area main {
  padding: 1.5rem;
  max-width: 1400px;
}

/* ---- Avatar ---- */
.avatar-circle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  font-size: .85rem;
  flex-shrink: 0;
}

/* ---- Navbar ---- */
#mainNavbar { height: var(--navbar-height); }

/* Toggle sidebar button (mobile) */
#sidebarToggle {
  display: none;
  background: none;
  border: none;
  color: #fff;
  font-size: 1.35rem;
  cursor: pointer;
  padding: .25rem .5rem;
  margin-right: .5rem;
}

/* ---- Notification badge ---- */
.notification-badge { font-size: .65rem; min-width:18px; }
.notification-dropdown .dropdown-item { white-space: normal; }

/* ---- Cards ---- */
.card {
  border: 1px solid var(--border);
  border-radius: .75rem;
  box-shadow: 0 2px 8px rgba(0,0,0,.06);
}
.card-header {
  border-radius: .75rem .75rem 0 0 !important;
  font-weight: 600;
}

/* ---- Stat cards ---- */
.stat-card {
  border-left: 4px solid var(--primary);
  transition: transform .15s, box-shadow .15s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,.1); }
.stat-card .stat-icon { font-size: 2rem; opacity: .25; }
.stat-card .stat-value { font-size: 2rem; font-weight: 700; }

/* ---- Badges ---- */
.badge { font-weight: 600; letter-spacing: .02em; }

/* ---- Status badge in tables ---- */
.status-pill {
  display: inline-block;
  padding: .28em .7em;
  border-radius: 50rem;
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
}

/* ---- Tables ---- */
.table th { font-weight: 600; font-size: .82rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); }
.table td { vertical-align: middle; }
.table-hover tbody tr:hover { background: rgba(13,110,253,.04); }

/* ---- Timeline / history ---- */
.timeline { position: relative; padding-left: 2rem; }
.timeline::before { content:''; position:absolute; left:.6rem; top:0; bottom:0; width:2px; background:var(--border); }
.timeline-item { position:relative; margin-bottom:1.25rem; }
.timeline-dot {
  position:absolute; left:-1.65rem; top:.15rem;
  width:14px; height:14px; border-radius:50%;
  background:var(--primary); border:2px solid #fff;
  box-shadow:0 0 0 2px var(--primary);
}
.timeline-dot.dot-success { background:#198754; box-shadow:0 0 0 2px #198754; }
.timeline-dot.dot-danger  { background:#dc3545; box-shadow:0 0 0 2px #dc3545; }
.timeline-dot.dot-warning { background:#ffc107; box-shadow:0 0 0 2px #ffc107; }

/* ---- Page header ---- */
.page-header {
  padding-bottom: 1rem;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
  display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:.5rem;
}
.page-header h1 { font-size: 1.4rem; font-weight: 700; margin: 0; }

/* ---- Empty state ---- */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-muted);
}
.empty-state i { font-size: 3.5rem; opacity: .3; display: block; margin-bottom: 1rem; }

/* ---- Utilities ---- */
.fw-600 { font-weight: 600; }
.text-xs  { font-size: .75rem; }
.text-sm  { font-size: .82rem; }
.rounded-lg { border-radius: .75rem !important; }
.shadow-soft { box-shadow: 0 4px 16px rgba(0,0,0,.08); }

/* ---- Handoff confirmation modal ---- */
.handoff-modal .form-label { font-weight: 600; }

/* ---- Modal scrollability fix (body has 56px navbar padding) ---- */
.modal-dialog {
  max-height: calc(100vh - var(--navbar-height) - 1rem);
}
.modal-dialog-scrollable {
  max-height: calc(100vh - var(--navbar-height) - 1rem);
}
.modal-dialog-scrollable .modal-content {
  max-height: calc(100vh - var(--navbar-height) - 1rem);
}
.modal-dialog-scrollable .modal-body {
  overflow-y: auto;
}

/* ---- Document status ---- */
.doc-card { transition: box-shadow .15s; }
.doc-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,.12); }

/* ---- Overdue highlight ---- */
.row-overdue td { background: rgba(220,53,69,.05); }
tr.row-overdue { border-left: 3px solid #dc3545; }

/* ---- Responsive: collapse sidebar on mobile ---- */
@media (max-width: 991.98px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .content-area {
    margin-left: 0;
  }
  #sidebarToggle {
    display: block;
  }
  .content-area main {
    padding: 1rem;
  }
}

/* ============================================================
   FILTER PANEL
   ============================================================ */

/* Collapsible filter card */
.filter-panel .card-body {
  padding: .85rem 1rem;
}
.filter-panel .form-label {
  font-weight: 600;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
  margin-bottom: .3rem;
}
.filter-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font-weight: 600;
  font-size: .85rem;
}
.filter-toggle-btn .bi-chevron-down {
  transition: transform .2s;
}
.filter-toggle-btn[aria-expanded="true"] .bi-chevron-down {
  transform: rotate(-180deg);
}

/* Active-filter count badge on the toggle button */
.filter-active-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 50rem;
  background: var(--primary);
  color: #fff;
  font-size: .65rem;
  font-weight: 700;
  line-height: 1;
}

/* ============================================================
   SORTABLE COLUMN HEADERS
   ============================================================ */
.th-sortable {
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
.th-sortable a.sort-link {
  color: inherit;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: .3rem;
}
.th-sortable a.sort-link:hover {
  color: var(--primary);
}
.sort-icon {
  font-size: .75rem;
  opacity: .35;
  transition: opacity .15s, color .15s;
}
.sort-icon.active {
  opacity: 1;
  color: var(--primary);
}

/* ============================================================
   RESULT SUMMARY BAR  (below filters, above table)
   ============================================================ */
.result-summary-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .5rem;
  padding: .5rem 1rem;
  background: #f8f9fa;
  border-bottom: 1px solid var(--border);
  font-size: .82rem;
  color: var(--text-muted);
}

/* ============================================================
   FILTER STATE PERSISTENCE (JS hook classes)
   ============================================================ */
.filter-panel-collapse {
  /* Handled by Bootstrap collapse; nothing extra needed */
}

