/*==============================================================
  PBRMS - Pharmacy Board Regulatory Management System
  Custom Stylesheet
==============================================================*/

:root {
  --sidebar-width:      240px;
  --sidebar-collapsed:  64px;
  --topbar-height:      56px;
  --prms-primary:       #1a3a5c;
  --prms-primary-dark:  #122845;
  --prms-primary-light: #234d78;
  --prms-secondary:     #0d6efd;
  --prms-success:       #198754;
  --prms-warning:       #ffc107;
  --prms-danger:        #dc3545;
  --prms-border:        #dee2e6;
  --sidebar-text:       rgba(255,255,255,0.85);
  --sidebar-text-muted: rgba(255,255,255,0.50);
  --sidebar-hover:      rgba(255,255,255,0.10);
  --sidebar-active:     rgba(255,255,255,0.18);
}

/* -------------------------------------------------------
   Reset / Base
------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 0.9rem;
  background-color: #f0f2f5;
  margin: 0;
  overflow-x: hidden;
}

/* -------------------------------------------------------
   SIDEBAR
------------------------------------------------------- */
.prms-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--prms-primary);
  display: flex;
  flex-direction: column;
  z-index: 1050;
  transition: width 0.25s ease, transform 0.25s ease;
  overflow: hidden;
}

/* Brand */
.sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  height: var(--topbar-height);
  background: var(--prms-primary-dark);
  flex-shrink: 0;
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: #fff;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  white-space: nowrap;
  overflow: hidden;
}

.brand-icon {
  font-size: 1.3rem;
  flex-shrink: 0;
  color: #7fb3e0;
}

.brand-text { transition: opacity 0.2s; }

.sidebar-close-btn {
  background: none;
  border: none;
  color: var(--sidebar-text-muted);
  font-size: 1rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
}
.sidebar-close-btn:hover { color: #fff; background: var(--sidebar-hover); }

/* User card */
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  flex-shrink: 0;
  overflow: hidden;
  background: rgba(0,0,0,0.1);
}

.user-avatar {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid rgba(255,255,255,0.3);
}
.user-avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-initials {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  background: var(--prms-secondary);
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
}

.user-info { overflow: hidden; white-space: nowrap; transition: opacity 0.2s; }
.user-name  { color: #fff; font-weight: 600; font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; }
.user-role  { color: var(--sidebar-text-muted); font-size: 0.72rem; overflow: hidden; text-overflow: ellipsis; }

/* Nav list */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  padding: 0.5rem 0;
  /* WebKit (Safari, Chrome < 121) */
  scrollbar-width: thin;                              /* Firefox */
  scrollbar-color: rgba(255,255,255,0.15) transparent; /* Firefox */
}
.sidebar-nav::-webkit-scrollbar       { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.3); }

.nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1;
}

.nav-item .nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 1rem;
  color: var(--sidebar-text);
  text-decoration: none;
  border-radius: 0;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
  position: relative;
}

.nav-item .nav-link:hover {
  background: var(--sidebar-hover);
  color: #fff;
}

.nav-item.active > .nav-link,
.nav-item.active > a {
  background: var(--sidebar-active);
  color: #fff;
  border-left: 3px solid #7fb3e0;
}

.nav-icon {
  width: 20px;
  text-align: center;
  font-size: 0.95rem;
  flex-shrink: 0;
}

.nav-label { flex: 1; font-size: 0.875rem; transition: opacity 0.2s; }

.nav-arrow {
  font-size: 0.65rem;
  transition: transform 0.25s;
  margin-left: auto;
  flex-shrink: 0;
}

/* Sub-menu */
.nav-group .nav-sub {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.3s ease;
  background: rgba(0,0,0,0.12);
}

.nav-group.open > .nav-link .nav-arrow { transform: rotate(90deg); }
.nav-group.open > .nav-sub { max-height: 400px; }

.nav-sub-link {
  display: block;
  padding: 0.5rem 1rem 0.5rem 3rem;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 0.83rem;
  transition: background 0.15s, color 0.15s;
}
.nav-sub-link:hover { background: var(--sidebar-hover); color: #fff; }
.nav-sub-link.active { color: #fff; font-weight: 600; }

.nav-sub-divider {
  border-top: 1px solid rgba(255,255,255,0.1);
  margin: 0.25rem 0;
}

/* Sidebar bottom links */
.sidebar-bottom {
  border-top: 1px solid rgba(255,255,255,0.1);
  padding: 0.5rem 0;
  flex-shrink: 0;
}
.sidebar-bottom .nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 0.875rem;
  transition: background 0.15s;
  white-space: nowrap;
}
.sidebar-bottom .nav-link:hover { background: var(--sidebar-hover); color: #fff; }
.sidebar-bottom .text-danger-soft { color: rgba(255,100,100,0.85) !important; }
.sidebar-bottom .text-danger-soft:hover { color: #ff6b6b !important; }

/* Overlay (mobile) */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background: rgba(0,0,0,0.45);
  z-index: 1040;
}
.sidebar-overlay.show { display: block; }

/* -------------------------------------------------------
   MAIN WRAPPER
------------------------------------------------------- */
.prms-main {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left 0.25s ease;
}

/* Collapsed state (desktop) */
.prms-sidebar.collapsed {
  width: var(--sidebar-collapsed);
}
.prms-sidebar.collapsed .brand-text,
.prms-sidebar.collapsed .user-info,
.prms-sidebar.collapsed .nav-label,
.prms-sidebar.collapsed .nav-arrow {
  opacity: 0;
  pointer-events: none;
  width: 0;
}
.prms-sidebar.collapsed .nav-item .nav-link { justify-content: center; gap: 0; padding: 0.65rem 0; }
.prms-sidebar.collapsed .sidebar-user       { justify-content: center; }
.prms-sidebar.collapsed .sidebar-bottom .nav-link { justify-content: center; gap: 0; padding: 0.6rem 0; }
.prms-sidebar.collapsed .nav-group .nav-sub { display: none; }
.prms-main.sidebar-collapsed { margin-left: var(--sidebar-collapsed); }

/* -------------------------------------------------------
   TOPBAR
------------------------------------------------------- */
.prms-topbar {
  height: var(--topbar-height);
  background: #fff;
  border-bottom: 1px solid var(--prms-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  position: sticky;
  top: 0;
  z-index: 1020;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  flex-shrink: 0;
}

.topbar-left  { display: flex; align-items: center; }
.topbar-right { display: flex; align-items: center; gap: 0.25rem; }

.sidebar-toggle-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  color: #555;
  font-size: 1.1rem;
  transition: background 0.15s, color 0.15s;
}
.sidebar-toggle-btn:hover { background: #f0f2f5; color: var(--prms-primary); }

.topbar-title {
  font-weight: 600;
  font-size: 1rem;
  color: var(--prms-primary);
}

/* Topbar icon buttons */
.topbar-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  color: #555;
  font-size: 1rem;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}
.topbar-icon-btn:hover { background: #f0f2f5; color: var(--prms-primary); }

.topbar-item { position: relative; }

/* Notification badge */
.notif-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  background: var(--prms-danger);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  border-radius: 10px;
  padding: 1px 4px;
  min-width: 16px;
  text-align: center;
  line-height: 14px;
}

/* Notification dropdown */
.notif-dropdown {
  min-width: 320px;
  max-width: 380px;
}
.notif-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 1rem;
  background: var(--prms-primary);
  color: #fff;
  font-size: 0.875rem;
  border-radius: 6px 6px 0 0;
}
.notif-mark-all { color: rgba(255,255,255,0.8); text-decoration: none; font-size: 0.78rem; }
.notif-mark-all:hover { color: #fff; }

.notif-body { max-height: 300px; overflow-y: auto; }

.notif-item {
  display: block;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid #f0f2f5;
  text-decoration: none;
  color: #333;
  transition: background 0.15s;
}
.notif-item:hover   { background: #f8f9fa; }
.notif-item.unread  { border-left: 3px solid var(--prms-secondary); background: rgba(13,110,253,0.04); }
.notif-title  { font-weight: 600; font-size: 0.82rem; margin-bottom: 2px; }
.notif-msg    { font-size: 0.78rem; color: #666; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.notif-time   { font-size: 0.7rem; color: #999; margin-top: 2px; }
.notif-empty  { text-align: center; padding: 1.5rem; color: #999; font-size: 0.85rem; }

.notif-footer {
  padding: 0.5rem;
  text-align: center;
  border-top: 1px solid #f0f2f5;
}
.notif-footer a { font-size: 0.82rem; color: var(--prms-secondary); text-decoration: none; }
.notif-footer a:hover { text-decoration: underline; }

/* Topbar user button */
.topbar-user-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: #333;
  padding: 0.3rem 0.5rem;
  border-radius: 6px;
  transition: background 0.15s;
}
.topbar-user-btn:hover { background: #f0f2f5; color: #333; }

.topbar-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--prms-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}
.topbar-avatar img { width: 100%; height: 100%; object-fit: cover; }
.topbar-username { font-size: 0.875rem; font-weight: 500; }

/* -------------------------------------------------------
   Flash / Content / Footer
------------------------------------------------------- */
.prms-flash   { flex-shrink: 0; }
.prms-content { flex: 1; min-height: 0; }
.prms-footer  {
  background: #fff;
  border-top: 1px solid var(--prms-border);
  padding: 0.75rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.78rem;
  color: #6c757d;
  flex-shrink: 0;
}

/* -------------------------------------------------------
   Cards
------------------------------------------------------- */
.card {
  border: none;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  border-radius: 10px;
}
.card-header {
  background-color: #fff;
  border-bottom: 1px solid var(--prms-border);
  font-weight: 600;
  font-size: 0.95rem;
}

/* Stat cards */
.stat-card {
  border-radius: 12px;
  border: none;
  transition: transform 0.2s, box-shadow 0.2s;
  overflow: hidden;
}
.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(0,0,0,0.12);
}
.stat-card .stat-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  opacity: 0.9;
}
.stat-card .stat-value { font-size: 2rem; font-weight: 700; line-height: 1; }
.stat-card .stat-label {
  font-size: 0.8rem;
  opacity: 0.85;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* -------------------------------------------------------
   Status Badges
------------------------------------------------------- */
.badge-draft              { background-color: #6c757d; color: #fff; }
.badge-submitted          { background-color: #0dcaf0; color: #000; }
.badge-under_review       { background-color: #ffc107; color: #000; }
.badge-inspection_required{ background-color: #fd7e14; color: #fff; }
.badge-inspection_done    { background-color: #6f42c1; color: #fff; }
.badge-approved           { background-color: #198754; color: #fff; }
.badge-rejected           { background-color: #dc3545; color: #fff; }
.badge-expired            { background-color: #dc3545; color: #fff; }
.badge-active             { background-color: #198754; color: #fff; }
.badge-pending            { background-color: #0dcaf0; color: #000; }
.badge-suspended          { background-color: #fd7e14; color: #fff; }
.badge-revoked            { background-color: #343a40; color: #fff; }

/* -------------------------------------------------------
   Tables
------------------------------------------------------- */
.table th {
  font-weight: 600;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: #6c757d;
  border-top: none;
  background-color: #f8f9fa;
}
.table-hover tbody tr:hover   { background-color: rgba(13,110,253,0.04); }
.table-row-overdue  { background-color: rgba(220,53,69,0.06) !important; }
.table-row-expiring { background-color: rgba(255,193,7,0.08) !important; }

/* -------------------------------------------------------
   Forms
------------------------------------------------------- */
.form-label {
  font-weight: 500;
  font-size: 0.875rem;
  color: #495057;
  margin-bottom: 0.3rem;
}
.form-control:focus, .custom-select:focus {
  border-color: var(--prms-secondary);
  box-shadow: 0 0 0 0.2rem rgba(13,110,253,0.15);
}

/* Multi-step form */
.step-indicator {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  position: relative;
}
.step-indicator::before {
  content: '';
  position: absolute;
  top: 20px;
  left: 10%;
  right: 10%;
  height: 2px;
  background-color: var(--prms-border);
  z-index: 0;
}
.step-indicator .step-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  z-index: 1;
}
.step-indicator .step-circle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: #dee2e6;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  color: #6c757d;
  transition: background-color 0.3s, color 0.3s;
}
.step-indicator .step-item.active .step-circle    { background-color: var(--prms-secondary); color: #fff; }
.step-indicator .step-item.completed .step-circle { background-color: var(--prms-success); color: #fff; }
.step-indicator .step-label {
  font-size: 0.72rem;
  margin-top: 0.4rem;
  color: #6c757d;
  text-align: center;
  font-weight: 500;
}
.step-indicator .step-item.active .step-label { color: var(--prms-secondary); font-weight: 600; }

/* -------------------------------------------------------
   File Upload Zone
------------------------------------------------------- */
.upload-zone {
  border: 2px dashed #ced4da;
  border-radius: 10px;
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background-color 0.2s;
  background-color: #fafafa;
}
.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--prms-secondary);
  background-color: rgba(13,110,253,0.04);
}
.upload-zone i { font-size: 2.5rem; color: #ced4da; display: block; margin-bottom: 0.75rem; }

/* -------------------------------------------------------
   Compliance Score
------------------------------------------------------- */
.compliance-score-circle {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  font-weight: 700;
  border: 5px solid;
}
.compliance-score-circle.score-high   { border-color: #198754; color: #198754; }
.compliance-score-circle.score-medium { border-color: #ffc107; color: #ffc107; }
.compliance-score-circle.score-low    { border-color: #dc3545; color: #dc3545; }

/* -------------------------------------------------------
   Map Container
------------------------------------------------------- */
#facilityMap {
  height: 450px;
  border-radius: 10px;
  background: #e9ecef;
}

/* -------------------------------------------------------
   Timeline
------------------------------------------------------- */
.timeline { position: relative; padding-left: 2rem; }
.timeline::before {
  content: '';
  position: absolute;
  left: 0.85rem;
  top: 0;
  bottom: 0;
  width: 2px;
  background-color: #dee2e6;
}
.timeline-item { position: relative; margin-bottom: 1.5rem; }
.timeline-item::before {
  content: '';
  position: absolute;
  left: -1.9rem;
  top: 0.3rem;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background-color: var(--prms-secondary);
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px var(--prms-secondary);
}
.timeline-item.completed::before { background-color: var(--prms-success); box-shadow: 0 0 0 2px var(--prms-success); }
.timeline-item.rejected::before  { background-color: var(--prms-danger);  box-shadow: 0 0 0 2px var(--prms-danger); }

/* -------------------------------------------------------
   Print
------------------------------------------------------- */
@media print {
  .prms-sidebar, .prms-topbar, .btn, .filter-bar, .prms-footer, .no-print { display: none !important; }
  .prms-main { margin-left: 0 !important; }
  .card { box-shadow: none; border: 1px solid #dee2e6; }
  body  { background: white; }
}

/* -------------------------------------------------------
   Responsive — mobile (< 992px): sidebar slides in
------------------------------------------------------- */
@media (max-width: 991.98px) {
  .prms-sidebar {
    transform: translateX(calc(-1 * var(--sidebar-width)));
    width: var(--sidebar-width) !important; /* override collapsed on mobile */
  }
  .prms-sidebar.show { transform: translateX(0); }
  /* Reset any collapsed classes on small screens */
  .prms-sidebar.collapsed { width: var(--sidebar-width) !important; }
  .prms-sidebar.collapsed .brand-text,
  .prms-sidebar.collapsed .user-info,
  .prms-sidebar.collapsed .nav-label,
  .prms-sidebar.collapsed .nav-arrow { opacity: 1 !important; pointer-events: auto !important; width: auto !important; }

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

  .stat-card .stat-value  { font-size: 1.5rem; }
  .prms-content           { padding: 0.75rem !important; }
  .step-indicator .step-label { display: none; }
}
