/* =====================================================================
   app.css - RKV LabConnect application styles (Bootstrap 5 theme)
   Medical laboratory admin interface
   ===================================================================== */

:root {
  --sidebar-width: 250px;
  --topbar-height: 56px;
  --brand-primary: #0d6efd;
  --brand-medical: #0f766e;
}

body.app-body {
  background: #f1f5f9;
  font-family: 'Segoe UI', system-ui, -apple-system, Roboto, sans-serif;
  min-height: 100vh;
}

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

/* ---------- Sidebar ---------- */
.app-sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  max-height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1040;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform .25s ease;
}
.sidebar-brand { flex: 0 0 auto; min-height: var(--topbar-height); background: #0b1220; }
.sidebar-nav { flex: 1 1 auto; overflow-y: auto; overscroll-behavior: contain; }
.brand-icon {
  width: 38px; height: 38px; border-radius: 10px;
  background: linear-gradient(135deg, #0d6efd, #0f766e);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; flex-shrink: 0;
}
.sidebar-section-title { letter-spacing: .06em; font-size: .68rem; font-weight: 700; }
.sidebar-link {
  color: #cbd5e1; border-radius: 8px; padding: .55rem .75rem;
  font-size: .9rem; display: flex; align-items: center;
  transition: background .15s, color .15s;
}
.sidebar-link:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar-link.active {
  background: linear-gradient(90deg, rgba(13,110,253,.85), rgba(15,118,110,.6));
  color: #fff; font-weight: 600;
}
.sidebar-overlay { display: none; }

/* Desktop collapsed state (toggle button in the topbar) */
.sidebar-collapse { text-decoration: none; line-height: 1; }
@media (min-width: 769px) {
  body.sidebar-collapsed .app-sidebar { transform: translateX(-100%); }
  body.sidebar-collapsed .app-main { margin-left: 0; }
}

/* ---------- Main column ---------- */
.app-main {
  flex: 1 1 auto;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100vh;
  transition: margin-left .25s ease;
}
.app-topbar { min-height: var(--topbar-height); position: sticky; top: 0; z-index: 1030; }
.app-content { flex: 1 1 auto; }
.app-footer { flex-shrink: 0; }

.avatar-circle {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, #0d6efd, #0f766e);
  color: #fff; display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .85rem;
}

/* ---------- Stat cards ---------- */
.stat-card {
  border: 0; border-radius: 14px; color: #fff; position: relative; overflow: hidden;
  box-shadow: 0 6px 18px rgba(15,23,42,.12);
}
.stat-card .stat-icon {
  width: 52px; height: 52px; border-radius: 12px;
  background: rgba(255,255,255,.22);
  display: flex; align-items: center; justify-content: center; font-size: 1.4rem;
}
.stat-card .stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1.1; }
.stat-card .stat-label { font-size: .78rem; opacity: .92; text-transform: uppercase; letter-spacing: .04em; }
.stat-card::after {
  content: ''; position: absolute; right: -30px; top: -30px;
  width: 110px; height: 110px; border-radius: 50%; background: rgba(255,255,255,.12);
}
.bg-grad-primary { background: linear-gradient(135deg, #1d4ed8, #0ea5e9); }
.bg-grad-success { background: linear-gradient(135deg, #047857, #10b981); }
.bg-grad-warning { background: linear-gradient(135deg, #b45309, #f59e0b); }
.bg-grad-danger  { background: linear-gradient(135deg, #b91c1c, #ef4444); }
.bg-grad-info    { background: linear-gradient(135deg, #0e7490, #22d3ee); }
.bg-grad-purple  { background: linear-gradient(135deg, #6d28d9, #a78bfa); }
.bg-grad-medical { background: linear-gradient(135deg, #0f766e, #2dd4bf); }
.bg-grad-slate   { background: linear-gradient(135deg, #334155, #64748b); }

/* ---------- Cards & tables ---------- */
.card { border: 0; border-radius: 12px; box-shadow: 0 2px 10px rgba(15,23,42,.06); }
.card-header { background: #fff; border-bottom: 1px solid #eef2f7; font-weight: 600; }
.table > :not(caption) > * > * { vertical-align: middle; }
.table thead th {
  background: #f8fafc; font-size: .75rem; text-transform: uppercase;
  letter-spacing: .04em; color: #475569; border-bottom-width: 1px; white-space: nowrap;
}
.table-hover tbody tr:hover { background: #f8fafc; }
.table-sm td, .table-sm th { padding: .55rem .65rem; }

/* ---------- Page header ---------- */
.page-header {
  display: flex; flex-wrap: wrap; gap: .75rem;
  align-items: center; justify-content: space-between; margin-bottom: 1rem;
}
.page-title { font-size: 1.25rem; font-weight: 700; color: #0f172a; margin: 0; }

/* ---------- Forms ---------- */
.form-control, .form-select { border-radius: 8px; }
.form-control:focus, .form-select:focus { border-color: #0d6efd; box-shadow: 0 0 0 .18rem rgba(13,110,253,.15); }
.btn { border-radius: 8px; }
.btn-primary { background: #0d6efd; border-color: #0d6efd; }
.label-required::after { content: ' *'; color: #dc3545; }

/* ---------- Empty state ---------- */
.empty-state {
  text-align: center; padding: 2.5rem 1rem; color: #94a3b8;
}
.empty-state i { font-size: 2.6rem; margin-bottom: .75rem; display: block; }

/* ---------- Loading ---------- */
.page-loader {
  position: fixed; inset: 0; background: rgba(255,255,255,.75);
  display: none; align-items: center; justify-content: center; z-index: 2000;
}
.page-loader.show { display: flex; }

/* ---------- Print / A4 report ---------- */
.report-sheet {
  background: #fff; max-width: 210mm; margin: 0 auto; padding: 12mm 12mm;
  font-size: 12px; color: #000; border: 1px solid #ddd;
}
.report-sheet .lab-header { border-bottom: 2px solid #0f766e; padding-bottom: 8px; margin-bottom: 10px; }
.report-sheet .lab-name { font-size: 20px; font-weight: 800; color: #0f766e; }
.report-sheet .result-table th { background: #f1f5f9; }
.report-sheet .abnormal { color: #dc2626; font-weight: 700; }
.report-sheet .sign-block { margin-top: 24px; }
.invoice-sheet { background:#fff; max-width: 210mm; margin: 0 auto; padding: 12mm; border: 1px solid #ddd; font-size: 12.5px; }

@media print {
  body.app-body { background: #fff; }
  .app-sidebar, .app-topbar, .app-footer, .no-print, .sidebar-overlay { display: none !important; }
  .app-main { margin-left: 0 !important; }
  .app-content { padding: 0 !important; }
  .report-sheet, .invoice-sheet { border: 0; padding: 0; max-width: 100%; }
  a[href]:after { content: '' !important; }
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
  .app-sidebar { transform: translateX(-100%); }
  body.sidebar-open .app-sidebar { transform: translateX(0); }
  body.sidebar-open .sidebar-overlay { display: block; position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 1035; }
  .app-main { margin-left: 0; }
}
@media (min-width: 769px) {
  .sidebar-toggle { display: none; }
}

/* Small helpers */
.text-medical { color: var(--brand-medical); }
.flex-1 { flex: 1 1 auto; min-width: 0; }
.cursor-pointer { cursor: pointer; }
.table-actions .btn { padding: .15rem .45rem; font-size: .8rem; }
.badge-outline { background: transparent; border: 1px solid currentColor; }
.select2-hidden-accessible + .select2 { width: 100% !important; }

/* Notifications bell */
.notif-count { position: absolute; top: 2px; right: 0; font-size: .6rem; }
.notif-list { max-height: 340px; overflow-y: auto; }
.notif-item:hover { background: #f1f3f5; }

/* Sidebar menu badges */
.sidebar-link .badge { margin-left: auto; }

/* ---------- Sidebar dropdown (accordion) groups ---------- */
.sidebar-group-toggle {
  color: #cbd5e1; border-radius: 8px; padding: .55rem .75rem;
  font-size: .82rem; font-weight: 600; letter-spacing: .03em;
  display: flex; align-items: center; width: 100%;
  transition: background .15s, color .15s;
}
.sidebar-group-toggle:hover { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
.sidebar-group-toggle:focus { color: #fff; box-shadow: none; }
.sidebar-group-toggle[aria-expanded="true"] { color: #fff; }
.sidebar-caret {
  margin-left: auto; font-size: .65rem; opacity: .75;
  transition: transform .2s ease;
}
.sidebar-group-toggle[aria-expanded="true"] .sidebar-caret { transform: rotate(180deg); }
.sidebar-submenu {
  margin: .15rem 0 .35rem .55rem;
  padding-left: .55rem;
  border-left: 1px solid rgba(255,255,255,.14);
}
.sidebar-submenu .sidebar-link { font-size: .85rem; padding: .45rem .65rem; }
