/* ==========================================================================
   MEDICARE PHARMACY - ADMIN & PHARMACIST PORTAL STYLESHEET
   Design System: Enterprise clinical dashboard, dark slate sidebar,
   high-density data tables, status badges, and smooth modal overlays.
   ========================================================================== */

:root {
  --admin-sidebar-bg: #041423;
  --admin-sidebar-hover: rgba(255, 255, 255, 0.08);
  --admin-sidebar-active: #0284c7;
  --admin-sidebar-text: #94a3b8;
  --admin-sidebar-text-active: #ffffff;

  --primary: #0284c7;
  --primary-hover: #0369a1;
  --primary-light: #e0f2fe;

  --emerald: #059669;
  --emerald-hover: #047857;
  --emerald-light: #d1fae5;

  --amber: #d97706;
  --amber-light: #fef3c7;

  --rose: #e11d48;
  --rose-light: #ffe4e6;

  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --border-color: #e2e8f0;
  
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-sub: #334155;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

.hidden {
  display: none !important;
}

/* ================= ADMIN LAYOUT ================= */
.admin-layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.admin-sidebar {
  width: 270px;
  background-color: var(--admin-sidebar-bg);
  color: var(--admin-sidebar-text);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
  transition: transform var(--transition-normal);
}

.sidebar-header {
  padding: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-info {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: -0.02em;
}

.accent-dot {
  color: #10b981;
}

.brand-sub {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #38bdf8;
  font-weight: 600;
}

.sidebar-close-btn {
  display: none;
  color: #ffffff;
  font-size: 1.25rem;
}

/* Sidebar Nav */
.sidebar-nav {
  padding: 1.25rem 1rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.nav-section-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
  font-weight: 700;
  padding: 0.75rem 0.75rem 0.35rem 0.75rem;
}

.nav-menu {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-md);
  color: var(--admin-sidebar-text);
  font-weight: 600;
  font-size: 0.875rem;
  transition: all var(--transition-fast);
  text-align: left;
}

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

.nav-item.active {
  background-color: var(--primary);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.3);
}

.nav-icon {
  font-size: 1.15rem;
}

.nav-badge {
  margin-left: auto;
  font-size: 0.7rem;
  font-weight: 800;
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
}

.nav-badge.badge-warning {
  background: var(--amber);
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 1.25rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.user-profile-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0284c7, #10b981);
  color: #ffffff;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
}

.user-info {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.user-info strong {
  font-size: 0.85rem;
  color: #ffffff;
}

.user-info span {
  font-size: 0.7rem;
  color: #94a3b8;
}

.btn-exit-store {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  background: rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  color: #cbd5e1;
  font-weight: 600;
  transition: all var(--transition-fast);
}

.btn-exit-store:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

/* ================= MAIN CONTENT ================= */
.admin-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 1.75rem 2.25rem;
}

/* Topbar */
.admin-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
  gap: 1.5rem;
}

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

.mobile-toggle-btn {
  display: none;
  font-size: 1.5rem;
  color: var(--text-main);
}

.page-current-title {
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

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

.admin-search-box input {
  padding: 0.55rem 1rem;
  background: #ffffff;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-full);
  font-size: 0.875rem;
  width: 240px;
  transition: all var(--transition-fast);
}

.admin-search-box input:focus {
  outline: none;
  border-color: var(--primary);
  width: 280px;
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.12);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 600;
  padding: 0.55rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  transition: all var(--transition-fast);
}

.btn-sm {
  padding: 0.4rem 0.85rem;
  font-size: 0.825rem;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-emerald {
  background: var(--emerald);
  color: #ffffff;
}

.btn-emerald:hover {
  background: var(--emerald-hover);
}

.btn-outline-primary {
  border: 1.5px solid var(--primary);
  color: var(--primary);
}

.btn-outline-primary:hover {
  background: var(--primary-light);
}

.btn-outline-secondary {
  border: 1.5px solid var(--border-color);
  color: var(--text-sub);
}

.btn-outline-secondary:hover {
  background: #f1f5f9;
}

.btn-outline-danger {
  border: 1.5px solid var(--rose);
  color: var(--rose);
}

.btn-outline-danger:hover {
  background: var(--rose-light);
}

.btn-link {
  color: var(--primary);
  font-weight: 700;
  font-size: 0.85rem;
}

.btn-link:hover {
  text-decoration: underline;
}

.btn-block {
  width: 100%;
}

/* ================= TAB CONTENTS ================= */
.tab-content {
  display: none;
  animation: fadeIn 0.25s ease-out;
}

.tab-content.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.view-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.view-header-bar h2 {
  font-size: 1.4rem;
  font-weight: 800;
}

.view-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.view-actions-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.filter-select {
  padding: 0.5rem 0.85rem;
  background: #ffffff;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-sub);
}

/* ================= STATS CARDS ================= */
.stat-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.75rem;
}

.stat-card {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}

.stat-icon-wrap {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

.bg-blue-subtle { background: #e0f2fe; }
.bg-emerald-subtle { background: #d1fae5; }
.bg-amber-subtle { background: #fef3c7; }
.bg-purple-subtle { background: #f3e8ff; }

.stat-details {
  display: flex;
  flex-direction: column;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.2rem;
}

.stat-value {
  font-size: 1.6rem;
  font-weight: 800;
  line-height: 1.1;
  color: var(--text-main);
  margin-bottom: 0.25rem;
}

.stat-trend {
  font-size: 0.75rem;
  font-weight: 600;
}

.trend-up { color: var(--emerald); }
.trend-amber { color: var(--amber); }
.trend-neutral { color: var(--text-muted); }

/* ================= DASHBOARD ANALYTICS GRID ================= */
.dashboard-analytics-grid {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 1.5rem;
  margin-bottom: 1.75rem;
}

.dashboard-panel {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.panel-header h3 {
  font-size: 1.05rem;
  font-weight: 700;
}

.panel-tag {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-light);
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-full);
}

/* Category Bars */
.category-bars-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.cat-bar-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.cat-bar-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.825rem;
  font-weight: 600;
}

.cat-bar-track {
  height: 8px;
  background: #f1f5f9;
  border-radius: var(--radius-full);
  overflow: hidden;
}

.cat-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: linear-gradient(90deg, #0284c7, #10b981);
}

/* Quick Rx Tasks Feed */
.quick-tasks-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.quick-task-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  background: #f8fafc;
  border: 1px solid var(--border-color);
}

.task-info strong {
  display: block;
  font-size: 0.85rem;
  color: var(--text-main);
}

.task-info span {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ================= TABLES ================= */
.table-responsive {
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.875rem;
}

.admin-table th {
  padding: 0.85rem 1rem;
  background: #f8fafc;
  border-bottom: 2px solid var(--border-color);
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.admin-table td {
  padding: 0.95rem 1rem;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

.admin-table tbody tr:hover {
  background-color: #f8fafc;
}

/* Status Badges */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.65rem;
  border-radius: var(--radius-full);
}

.status-emerald { background: #d1fae5; color: #065f46; }
.status-amber { background: #fef3c7; color: #92400e; }
.status-blue { background: #e0f2fe; color: #0369a1; }
.status-rose { background: #ffe4e6; color: #9f1239; }

/* Table Action Buttons */
.table-actions-cell {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.btn-icon-action {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  background: #f1f5f9;
  color: var(--text-sub);
  transition: all var(--transition-fast);
}

.btn-icon-action:hover {
  background: #e2e8f0;
  color: var(--text-main);
}

.btn-icon-action.danger:hover {
  background: #fee2e2;
  color: var(--rose);
}

/* Table Item Thumbnail */
.table-product-cell {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.table-product-thumb {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: #f1f5f9;
  border: 1px solid var(--border-color);
}

.table-product-info strong {
  display: block;
  font-size: 0.85rem;
  color: var(--text-main);
}

.table-product-info span {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ================= MODALS ================= */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.modal-dialog {
  background: #ffffff;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
  width: 100%;
}

.modal-form { max-width: 680px; padding: 2rem; }
.modal-form-sm { max-width: 440px; padding: 2rem; }
.modal-rx-doc { max-width: 780px; padding: 2rem; }

.modal-header {
  margin-bottom: 1.5rem;
}

.modal-header h3 {
  font-size: 1.35rem;
  font-weight: 800;
}

.modal-sub {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.modal-close-btn {
  position: absolute;
  top: 1.25rem;
  right: 1.25rem;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.form-row.three-cols {
  grid-template-columns: 1.2fr 0.9fr 0.9fr;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.form-field label {
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--text-sub);
}

.form-field input, .form-field select, .form-field textarea {
  padding: 0.6rem 0.85rem;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
}

.form-field input:focus, .form-field select:focus, .form-field textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.12);
}

.modal-footer-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
}

/* Rx Doc Inspection */
.rx-doc-preview-body {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 1.75rem;
}

.rx-doc-image-container {
  background: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  height: 340px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.rx-doc-image-container img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.checklist {
  list-style: none;
  font-size: 0.85rem;
  color: var(--text-sub);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 1rem 0 1.5rem 0;
}

.checklist li {
  padding: 0.5rem;
  background: #f8fafc;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.rx-doc-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* Toggle Switch */
.custom-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  cursor: pointer;
  user-select: none;
}

.custom-toggle input {
  display: none;
}

.toggle-slider {
  width: 40px;
  height: 22px;
  background: #cbd5e1;
  border-radius: var(--radius-full);
  position: relative;
  transition: background var(--transition-fast);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  background: #ffffff;
  border-radius: 50%;
  transition: transform var(--transition-fast);
}

.custom-toggle input:checked + .toggle-slider {
  background: var(--emerald);
}

.custom-toggle input:checked + .toggle-slider::before {
  transform: translateX(18px);
}

.toggle-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
}

/* ================= TOAST ================= */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 600;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.toast {
  padding: 0.75rem 1.25rem;
  background: #ffffff;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xl);
  font-size: 0.875rem;
  font-weight: 600;
  border-left: 4px solid var(--primary);
  animation: fadeIn 0.3s ease;
}

.toast.toast-success { border-left-color: var(--emerald); }
.toast.toast-error { border-left-color: var(--rose); }

/* ================= RESPONSIVE ================= */
@media (max-width: 1024px) {
  .dashboard-analytics-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .admin-sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    transform: translateX(-100%);
  }

  .admin-sidebar.active {
    transform: translateX(0);
  }

  .sidebar-close-btn {
    display: block;
  }

  .mobile-toggle-btn {
    display: block;
  }

  .admin-main {
    padding: 1.25rem;
  }

  .rx-doc-preview-body {
    grid-template-columns: 1fr;
  }

  .form-row, .form-row.three-cols {
    grid-template-columns: 1fr;
  }
}
