/* ===========================================================
   COMMON.CSS
   Shared styles used across all RHU pages: reset, body,
   sidebar/nav/profile/dropup, main content shell, KPI cards,
   badges, toast notifications, modals, and utility classes.
   Standardized using the majority version found across files.
   =========================================================== */

/* ---------- RESET & BASE ---------- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background: linear-gradient(135deg, #f0f9ff, #f8fafc);
  font-family: "Segoe UI", Arial, sans-serif;
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ---------- SIDEBAR ---------- */
.sidebar {
  width: 260px;
  background: white;
  border-right: 1px solid #ebf3fb;
  height: 100vh;
  position: fixed;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  z-index: 100;
}

.sidebar-top {
  flex: 1;
  overflow-y: auto;
}

.logo-section {
  padding: 20px;
  border-bottom: 1px solid #ebf3fb;
}

.logo {
  font-size: 24px;
  font-weight: 700;
  color: #1d4ed8;
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo .icon,
.logo i {
  margin-right: 8px;
  color: #3b82f6;
}

.subtitle {
  font-size: 12px;
  color: #60a5fa;
  margin-top: 4px;
}

.sidebar-nav {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 12px;
  color: #1e3a8a;
  text-decoration: none;
  transition:
    background 0.2s,
    color 0.2s;
}

.nav-link:hover {
  background-color: #eff6ff;
  color: #1e40af;
}

.nav-icon {
  width: 20px;
  text-align: center;
}

.active-nav {
  background-color: #3b82f6;
  color: white;
}

.active-nav:hover {
  background-color: #2563eb;
  color: white;
}

.sidebar-bottom {
  padding: 16px;
  border-top: 1px solid #ebf3fb;
}

/* ---------- PROFILE / DROPUP ---------- */
.profile-container {
  position: relative;
}

.profile-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.profile-info {
  display: flex;
  gap: 8px;
  align-items: center;
}

.profile-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background-color: #bfdbfe;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #1d4ed8;
  font-size: 20px;
}

.profile-text .profile-name,
.profile-name {
  font-weight: 500;
  display: block;
  font-size: 14px;
}

.profile-text .profile-role,
.profile-role {
  font-size: 12px;
  color: #9ca3af;
}

.logout-btn {
  background-color: #f3f4f6;
  padding: 10px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  color: #4b5563;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.logout-btn:hover {
  background-color: #e5e7eb;
  color: #1d4ed8;
}

.dropup {
  position: absolute;
  bottom: 100%;
  right: 0;
  margin-bottom: 8px;
  width: 200px;
  background-color: white;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  display: none;
}

.dropup.show {
  display: block;
}

.dropup-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  font-size: 14px;
  color: #374151;
  text-decoration: none;
  transition: background 0.2s;
}

.dropup-link:hover {
  background-color: #f3f4f6;
}

.dropup-divider {
  border-top: 1px solid #f3f4f6;
}

.logout-link {
  color: #dc2626;
}

.hidden {
  display: none;
}

/* ---------- MAIN CONTENT SHELL ---------- */
.main-content {
  margin-left: 260px;
  padding: 32px 36px;
  width: calc(100% - 260px);
  min-height: 100vh;
}

/* ---------- KPI CARDS ---------- */
.kpi-card {
  background: white;
  border-radius: 16px;
  padding: 1.25rem;
  text-align: center;
  border: 1px solid #eef2f6;
  transition:
    transform 0.2s,
    box-shadow 0.2s;
}

.kpi-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 20px -12px rgba(0, 0, 0, 0.1);
}

.kpi-icon {
  font-size: 2rem;
  margin-bottom: 0.5rem;
  opacity: 0.85;
}

.kpi-value {
  font-size: 2rem;
  font-weight: 700;
  margin-top: 0.5rem;
}

.kpi-label {
  font-size: 0.875rem;
  color: #6b7280;
}

/* ---------- BADGES / STATUS PILLS ---------- */
.badge {
  padding: 0.2rem 0.6rem;
  border-radius: 30px;
  font-size: 0.7rem;
  font-weight: 600;
  display: inline-block;
}

.badge-pending {
  background: #fef3c7;
  color: #b45309;
}

.badge-claimed {
  background: #d1fae5;
  color: #065f46;
}

.badge-partial {
  background: #fed7aa;
  color: #9a3412;
}

/* ---------- TOAST NOTIFICATION ---------- */
.toast-notification {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: #10b981;
  color: white;
  padding: 12px 20px;
  border-radius: 40px;
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 8px;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s ease;
}

.toast-notification.show {
  transform: translateY(0);
  opacity: 1;
}

/* ---------- MODAL ---------- */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal.show {
  display: flex;
}

.modal-content {
  background: white;
  border-radius: 1rem;
  width: 90%;
  max-width: 1000px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 1.5rem;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #e5e7eb;
  padding-bottom: 12px;
  margin-bottom: 16px;
}

.modal-title {
  font-size: 20px;
  font-weight: 600;
}

.modal-footer {
  text-align: right;
  margin-top: 16px;
}

.btn-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
}

.close-modal {
  font-size: 1.8rem;
  cursor: pointer;
}

/* ---------- PAGE HEADER (title + date row, shared across pages) ---------- */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 28px;
  flex-wrap: wrap;
  gap: 1rem;
}
.page-title {
  font-size: 1.875rem;
  font-weight: 800;
  color: #1f2937;
  display: flex;
  align-items: center;
  gap: 12px;
}
.page-title i {
  color: #10b981;
}

/* ---------- TOP BAR (uniform across all staff pages) ---------- */
.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  background: linear-gradient(135deg, #e0f2fe, #eef9ff);
  padding: 14px 24px;
  border-radius: 1rem;
  margin: -8px -8px 20px;
  flex-wrap: wrap;
  position: relative;
  z-index: 50;
}

.top-bar-search {
  position: relative;
  flex: 1;
  max-width: 420px;
}

.top-bar-search i.fa-search {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: #64748b;
  font-size: 0.9rem;
  pointer-events: none;
}

.top-bar-search input {
  width: 100%;
  padding: 0.6rem 2.5rem 0.6rem 2.5rem;
  border: 1px solid #e2e8f0;
  border-radius: 9999px;
  background: white;
  font-size: 0.875rem;
  font-family: inherit;
  box-sizing: border-box;
}

.top-bar-search input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px #bfdbfe;
}

.clear-search-btn {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: #9ca3af;
  cursor: pointer;
  font-size: 0.8rem;
  padding: 4px;
}

.top-bar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.refresh-btn {
  background: white;
  padding: 0.55rem 1.1rem;
  border-radius: 9999px;
  border: 1px solid #dbeafe;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.875rem;
  font-weight: 600;
  color: #1d4ed8;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  box-shadow: 0 2px 6px rgba(59, 130, 246, 0.12);
}

.refresh-btn:hover {
  background: #3b82f6;
  border-color: #3b82f6;
  color: white;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.28);
  transform: translateY(-1px);
}

.refresh-btn:active {
  transform: translateY(0);
}

.bell-container {
  position: relative;
  display: inline-block;
}

#globalNotificationBtn {
  background: white;
  border: 1px solid #dbeafe;
  width: 40px;
  height: 40px;
  border-radius: 9999px;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(59, 130, 246, 0.12);
  transition: all 0.2s;
  font-size: 1rem;
  color: #1d4ed8;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

#globalNotificationBtn:hover {
  background: #3b82f6;
  border-color: #3b82f6;
  color: white;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.28);
  transform: translateY(-1px);
}

#globalNotificationBtn:active {
  transform: translateY(0);
}

.global-notification-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: white;
  border-radius: 40px;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border: 2px solid white;
  min-width: 20px;
  text-align: center;
  box-shadow: 0 2px 6px rgba(220, 38, 38, 0.35);
}

/* Search results dropdown — anchored to .top-bar-search */
.search-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: 100%;
  min-width: 280px;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 0.75rem;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.15);
  z-index: 500;
  max-height: 320px;
  overflow-y: auto;
}

.search-dropdown-section-label {
  padding: 8px 14px 4px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #94a3b8;
}

.search-dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 1rem;
  font-size: 0.85rem;
  cursor: pointer;
  color: #1e293b;
}

.search-dropdown-item i {
  color: #3b82f6;
  width: 16px;
  text-align: center;
  flex-shrink: 0;
}

.search-dropdown-item:hover {
  background: #eff6ff;
}

.search-dropdown-item .item-sub {
  margin-left: auto;
  font-size: 0.7rem;
  color: #94a3b8;
  background: #f1f5f9;
  padding: 2px 8px;
  border-radius: 8px;
}

.search-dropdown-empty {
  padding: 0.75rem 1rem;
  font-size: 0.8rem;
  color: #9ca3af;
}

/* Notification popover */
.popover-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 300px;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 0.9rem;
  box-shadow: 0 12px 28px -6px rgba(0, 0, 0, 0.18);
  z-index: 500;
  overflow: hidden;
}

.popover-header {
  padding: 12px 16px;
  font-size: 0.85rem;
  font-weight: 700;
  color: #1f2937;
  border-bottom: 1px solid #f1f5f9;
}

.popover-list {
  max-height: 260px;
  overflow-y: auto;
}

.popover-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 16px;
  border-bottom: 1px dashed #f1f5f9;
  cursor: pointer;
  font-size: 0.8rem;
}

.popover-item:hover {
  background: #f8fafc;
}

.popover-item .popover-item-title {
  font-weight: 600;
  color: #1e293b;
  display: flex;
  align-items: center;
  gap: 6px;
}

.popover-item .popover-item-title i {
  color: #f59e0b;
  font-size: 0.75rem;
}

.popover-item .popover-item-meta {
  color: #94a3b8;
  font-size: 0.72rem;
}

.popover-empty {
  padding: 16px;
  text-align: center;
  color: #9ca3af;
  font-size: 0.8rem;
}

.popover-footer-link {
  display: block;
  text-align: center;
  padding: 10px;
  font-size: 0.8rem;
  font-weight: 600;
  color: #1d4ed8;
  text-decoration: none;
  border-top: 1px solid #f1f5f9;
  background: #f8fafc;
}

.popover-footer-link:hover {
  background: #eff6ff;
}

/* ---------- BREADCRUMB ---------- */
.breadcrumb-nav {
  margin: 0 0 16px;
}

.breadcrumb {
  display: flex;
  align-items: center;
  list-style: none;
  flex-wrap: wrap;
  padding: 0;
  margin: 0;
  font-size: 0.85rem;
}

.breadcrumb-item {
  display: flex;
  align-items: center;
  color: #6b7280;
}

.breadcrumb-item + .breadcrumb-item::before {
  content: ">";
  margin: 0 8px;
  color: #cbd5e1;
}

.breadcrumb-item a {
  color: #1d4ed8;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 5px;
}

.breadcrumb-item a:hover {
  text-decoration: underline;
}

.breadcrumb-item.active {
  color: #1f2937;
  font-weight: 600;
}

/* ---------- DATE DISPLAY (shared header element) ---------- */
#currentDate {
  background: white;
  padding: 8px 16px;
  border-radius: 9999px;
  font-size: 0.875rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  display: flex;
  align-items: center;
  gap: 8px;
}

.date-badge {
  background: white;
  padding: 8px 16px;
  border-radius: 9999px;
  font-size: 0.875rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ---------- LOADING SPINNER ---------- */
.loading-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid #e5e7eb;
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-right: 8px;
}

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

/* ---------- SHARED UTILITY CLASSES ---------- */
.flex {
  display: flex;
}
.flex-col {
  flex-direction: column;
}
.flex-1 {
  flex: 1;
}
.items-center {
  align-items: center;
}
.items-start {
  align-items: flex-start;
}
.justify-between {
  justify-content: space-between;
}
.justify-center {
  justify-content: center;
}
.text-center {
  text-align: center;
}
.text-left {
  text-align: left;
}
.cursor-pointer {
  cursor: pointer;
}
.w-full {
  width: 100%;
}
.relative {
  position: relative;
}
.overflow-y-auto {
  overflow-y: auto;
}
.overflow-x-auto {
  overflow-x: auto;
}

.gap-2 {
  gap: 8px;
}
.gap-3 {
  gap: 12px;
}
.gap-4 {
  gap: 16px;
}
.gap-6 {
  gap: 24px;
}

.mr-2 {
  margin-right: 8px;
}
.mt-2 {
  margin-top: 8px;
}
.mt-4 {
  margin-top: 16px;
}
.mb-2 {
  margin-bottom: 8px;
}
.mb-4 {
  margin-bottom: 16px;
}

.p-2 {
  padding: 8px;
}
.p-3 {
  padding: 12px;
}
.p-4 {
  padding: 16px;
}
.p-8 {
  padding: 32px;
}

.rounded {
  border-radius: 4px;
}
.rounded-lg {
  border-radius: 8px;
}
.rounded-xl {
  border-radius: 12px;
}
.rounded-full {
  border-radius: 9999px;
}

.border {
  border: 1px solid #e5e7eb;
}
.border-b {
  border-bottom: 1px solid #e5e7eb;
}

.bg-white {
  background: white;
}
.bg-gray-100 {
  background: #f3f4f6;
}

.text-xs {
  font-size: 12px;
}
.text-sm {
  font-size: 14px;
}
.text-xl {
  font-size: 20px;
}
.text-2xl {
  font-size: 24px;
}
.font-medium {
  font-weight: 500;
}
.font-semibold {
  font-weight: 600;
}
.font-bold {
  font-weight: 700;
}

.text-gray-400 {
  color: #9ca3af;
}
.text-gray-500 {
  color: #6b7280;
}
.text-gray-600 {
  color: #4b5563;
}
.text-gray-700 {
  color: #374151;
}
.text-blue-600 {
  color: #2563eb;
}
.text-blue-700 {
  color: #1d4ed8;
}
.text-green-600 {
  color: #059669;
}
.text-red-600 {
  color: #dc2626;
}

.space-y-3 > * + * {
  margin-top: 12px;
}
.space-y-4 > * + * {
  margin-top: 16px;
}
.space-y-6 > * + * {
  margin-top: 24px;
}

.grid {
  display: grid;
}
.grid-cols-2 {
  grid-template-columns: repeat(2, 1fr);
}
.grid-cols-3 {
  grid-template-columns: repeat(3, 1fr);
}
.grid-cols-4 {
  grid-template-columns: repeat(4, 1fr);
}

/* ---------- MOBILE MENU TOGGLE & OVERLAY ---------- */
.menu-toggle {
  display: none;
  position: fixed;
  top: 14px;
  left: 16px;
  z-index: 200;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: none;
  background: white;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  color: #1d4ed8;
  cursor: pointer;
}

.menu-toggle:active {
  background: #eff6ff;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 99;
}

.sidebar-overlay.show {
  display: block;
}

/* ---------- TABLE SCROLL WRAPPER ---------- */
.table-wrapper,
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ---------- SHARED RESPONSIVE BEHAVIOR ---------- */
@media (max-width: 768px) {
  .menu-toggle {
    display: flex;
  }

  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    width: 260px;
  }

  .sidebar.active {
    transform: translateX(0);
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.15);
  }

  .main-content {
    margin-left: 0;
    padding: 76px 16px 24px;
    width: 100%;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .top-bar {
    margin: 60px -8px 16px;
  }
  .top-bar-search {
    max-width: none;
    order: 2;
    width: 100%;
  }
  .top-bar-actions {
    order: 1;
    margin-left: auto;
  }
  .popover-panel {
    width: 280px;
    right: -40px;
  }

  .grid-cols-4 {
    grid-template-columns: repeat(2, 1fr);
  }
  .grid-cols-2 {
    grid-template-columns: 1fr;
  }
  .grid-cols-3 {
    grid-template-columns: repeat(2, 1fr);
  }

  table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
  }

  .modal-content {
    width: 94%;
    max-height: 90vh;
    padding: 1.25rem;
  }
}

@media (max-width: 480px) {
  .main-content {
    padding: 72px 12px 20px;
  }

  .grid-cols-4,
  .grid-cols-3,
  .grid-cols-2 {
    grid-template-columns: 1fr;
  }

  .page-title {
    font-size: 1.4rem;
  }

  .kpi-value {
    font-size: 1.5rem;
  }

  #currentDate {
    font-size: 0.8rem;
    padding: 6px 12px;
  }

  .date-badge {
    font-size: 0.8rem;
    padding: 6px 12px;
  }
}
