/* ===== PHDC QR-ID System - Layout ===== */
:root {
  --sidebar-width: 250px;
  --sidebar-bg: #1f2937;
  --sidebar-active: #2563eb;
  --topbar-h: 60px;
}

.app-body {
  background: #f1f5f9;
  min-height: 100vh;
}

.app-wrapper {
  display: flex;
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.app-sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: #e5e7eb;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 1040;
  transition: margin-left .25s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  padding: 1rem 1.25rem;
  font-weight: 700;
  font-size: 1.05rem;
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.sidebar-user .avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--sidebar-active);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  flex-shrink: 0;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: .75rem 0;
}

.sidebar-footer {
  border-top: 1px solid rgba(255, 255, 255, .08);
  padding: .5rem 0;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .65rem 1.25rem;
  color: #cbd5e1;
  text-decoration: none;
  font-size: .92rem;
  transition: background .15s ease, color .15s ease;
}

.sidebar-link i {
  width: 20px;
  text-align: center;
}

.sidebar-link:hover {
  background: rgba(255, 255, 255, .06);
  color: #fff;
}

.sidebar-link.active {
  background: var(--sidebar-active);
  color: #fff;
}

/* Highlight the parent button whenever its submenu is open/expanded. */
.sidebar-link[aria-expanded="true"] {
  background: var(--sidebar-active);
  color: #fff;
}

.sidebar-link .submenu-chevron {
  width: auto;
  transition: transform .2s ease;
}

.sidebar-link[aria-expanded="true"] .submenu-chevron {
  transform: rotate(180deg);
}

.sidebar-submenu {
  background: rgba(0, 0, 0, .25);
}

.sidebar-link.sublink {
  padding-left: 3rem;
  font-size: .85rem;
}

/* ---------- Main area ---------- */
.app-main {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-topbar {
  height: var(--topbar-h);
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  padding: 0 1.25rem;
  position: sticky;
  top: 0;
  z-index: 1030;
}

.app-content {
  padding: 1.5rem;
  flex: 1;
}

/* Collapsed (desktop) state */
.app-wrapper.sidebar-collapsed .app-sidebar {
  margin-left: calc(var(--sidebar-width) * -1);
}

.app-wrapper.sidebar-collapsed .app-main {
  margin-left: 0;
}

/* Mobile drawer backdrop */
.sidebar-backdrop {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, .5);
  z-index: 1039;
}

/* ---------- Cards ---------- */
.app-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: .5rem;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .06);
}

.app-card .app-card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
  border-radius: .5rem .5rem 0 0;
}

.app-card .app-card-body {
  padding: 1.25rem;
}

.stat-card .card-body { padding: 1.25rem; }
.stat-card .stat-icon {
  font-size: 1.8rem;
  opacity: .9;
}

.bg-teal { background-color: #0d9488; }

/* DataTables tweaks */
table.dataTable thead th {
  white-space: nowrap;
}

.table-nowrap td, .table-nowrap th { white-space: nowrap; }

/* Status badges */
.badge-status-pending { background-color: #f59e0b; color: #fff; }
.badge-status-approved { background-color: #22c55e; color: #fff; }
.badge-status-rejected { background-color: #ef4444; color: #fff; }

/* Login screen */
.login-screen {
  background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-screen .card { max-width: 420px; width: 100%; }

/* ---------- Loading spinner ---------- */
#loading-overlay {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(255, 255, 255, 0.8);
  z-index: 9999;
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.spinner-indigo { color: #4b0082; width: 3rem; height: 3rem; }

.btn-loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}
.btn-loading::after {
  content: "";
  position: absolute;
  width: 1.2rem;
  height: 1.2rem;
  top: 50%;
  left: 50%;
  margin-top: -0.6rem;
  margin-left: -0.6rem;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: white;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 991.98px) {
  /* Sidebar is hidden by default on mobile (off-canvas) */
  .app-sidebar { margin-left: calc(var(--sidebar-width) * -1); }
  .app-main { margin-left: 0; }
  .app-wrapper.sidebar-collapsed .app-sidebar { margin-left: calc(var(--sidebar-width) * -1); }
  .app-wrapper.sidebar-collapsed .app-main { margin-left: 0; }
  .app-wrapper.sidebar-open .app-sidebar {
    margin-left: 0;
    box-shadow: 4px 0 16px rgba(0, 0, 0, .25);
  }
  .app-wrapper.sidebar-open .sidebar-backdrop { display: block; }
}

/* Tighter app-content padding on very small screens */
@media (max-width: 575.98px) {
  .app-content { padding: 1rem; }
  .login-screen { padding: 1rem; }
}

/* Topbar title shrinks/truncates on small screens instead of wrapping */
.app-topbar h5 {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 991.98px) {
  .app-topbar h5 { margin-left: .75rem; }
}

/* Notification bell + dropdown */
.notif-badge { font-size: .6rem; padding: .2em .5em; }
.notif-menu { width: 340px; max-width: calc(100vw - 2rem); }
.notif-header { border-bottom: 1px solid #e9ecef; }
.notif-list { max-height: 320px; overflow-y: auto; }
.notif-item { white-space: normal; }
.notif-item.unread { background-color: #f0f5ff; }
.notif-dot { font-size: .5rem; color: #adb5bd; }
.notif-item.unread .notif-dot { color: #0d6efd; }
