/*
 * BNH Hospital theme - sits on top of AdminLTE 3 / Bootstrap 4 so every
 * existing page picks up the new look without per-page changes.
 */

:root {
  --bnh-primary: #0f766e;
  --bnh-primary-600: #0d9488;
  --bnh-primary-700: #115e59;
  --bnh-primary-50: #f0fdfa;
  --bnh-primary-100: #ccfbf1;
  --bnh-accent: #2563eb;
  --bnh-bg: #f3f6f9;
  --bnh-surface: #ffffff;
  --bnh-border: #e3e8ef;
  --bnh-text: #1e293b;
  --bnh-muted: #64748b;
  --bnh-sidebar: #0b1324;
  --bnh-sidebar-text: #b6c2d4;
  --bnh-success: #15803d;
  --bnh-warning: #b45309;
  --bnh-danger: #dc2626;
  --bnh-radius: 12px;
  --bnh-radius-sm: 8px;
  --bnh-shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .08);
  --bnh-shadow-lg: 0 12px 32px -12px rgba(15, 23, 42, .25);
  --bnh-font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ---------- base ---------- */
body,
.tooltip,
.popover {
  font-family: var(--bnh-font);
}

body {
  font-size: .925rem;
  color: var(--bnh-text);
  background: var(--bnh-bg);
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--bnh-primary);
}

a:hover {
  color: var(--bnh-primary-700);
}

.content-wrapper {
  background: var(--bnh-bg);
}

.content-header {
  padding: 22px 1rem 8px;
}

.content-header h1,
.content-header .m-0 {
  font-size: 1.45rem;
  font-weight: 650;
  letter-spacing: -.01em;
  color: var(--bnh-text);
}

.breadcrumb {
  font-size: .82rem;
}

.breadcrumb-item.active {
  color: var(--bnh-muted);
}

::selection {
  background: var(--bnh-primary-100);
}

/* thin, quiet scrollbars */
* {
  scrollbar-width: thin;
  scrollbar-color: #c3cad6 transparent;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-thumb {
  background: #c3cad6;
  border-radius: 10px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

/* ---------- top bar ---------- */
.main-header.navbar {
  background: rgba(255, 255, 255, .92);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--bnh-border);
  min-height: 58px;
}

.main-header .nav-link {
  color: #475569;
  border-radius: var(--bnh-radius-sm);
}

.main-header .nav-link:hover {
  color: var(--bnh-primary);
  background: var(--bnh-primary-50);
}

.bnh-topbar-title {
  font-weight: 600;
  color: var(--bnh-text);
}

.bnh-user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px 4px 4px !important;
}

.bnh-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  background: var(--bnh-primary);
  color: #fff;
  font-weight: 600;
  font-size: .85rem;
  flex-shrink: 0;
}

.bnh-user-chip .bnh-user-meta {
  line-height: 1.15;
  text-align: left;
}

.bnh-user-chip .bnh-user-meta small {
  color: var(--bnh-muted);
  display: block;
}

.dropdown-menu {
  border: 1px solid var(--bnh-border);
  border-radius: var(--bnh-radius);
  box-shadow: var(--bnh-shadow-lg);
  padding: 6px;
}

.dropdown-item {
  border-radius: 6px;
  padding: .45rem .75rem;
}

.dropdown-item:active,
.dropdown-item.active {
  background: var(--bnh-primary);
}

/* sync status pill */
.bnh-sync {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--bnh-border);
  background: #fff;
  border-radius: 999px;
  padding: 5px 12px;
  font-size: .8rem;
  font-weight: 600;
  color: #334155;
  cursor: pointer;
  white-space: nowrap;
}

.bnh-sync:hover {
  border-color: var(--bnh-primary);
}

.bnh-sync .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #94a3b8;
}

.bnh-sync.is-online .dot {
  background: #16a34a;
  box-shadow: 0 0 0 3px rgba(22, 163, 74, .18);
}

.bnh-sync.is-offline .dot {
  background: #f59e0b;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, .2);
}

.bnh-sync.is-error .dot {
  background: var(--bnh-danger);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, .18);
}

.bnh-sync.is-busy .fa-sync-alt {
  animation: bnh-spin 1s linear infinite;
}

.bnh-sync .fa-sync-alt {
  color: var(--bnh-muted);
  font-size: .75rem;
}

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

/* ---------- sidebar ---------- */
.main-sidebar,
.main-sidebar::before {
  background: var(--bnh-sidebar) !important;
}

.main-sidebar {
  box-shadow: none !important;
  border-right: 1px solid rgba(255, 255, 255, .04);
}

.brand-link {
  display: flex !important;
  align-items: center;
  gap: 10px;
  height: 58px;
  border-bottom: 1px solid rgba(255, 255, 255, .06) !important;
  padding: 0 14px !important;
}

.brand-link .brand-image {
  float: none !important;
  margin: 0 !important;
  max-height: 34px;
  width: 34px;
  height: 34px;
  object-fit: contain;
  background: #fff;
  border-radius: 9px;
  padding: 3px;
  box-shadow: none !important;
  opacity: 1 !important;
}

.brand-link .brand-text {
  color: #fff;
  font-weight: 650 !important;
  letter-spacing: .01em;
}

.brand-link .brand-text small {
  display: block;
  font-size: .68rem;
  font-weight: 500;
  color: var(--bnh-sidebar-text);
  letter-spacing: .06em;
  text-transform: uppercase;
}

.sidebar {
  padding: 8px 10px 16px;
}

.nav-sidebar .nav-header {
  color: #64748b;
  font-size: .68rem;
  font-weight: 650;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 1rem .75rem .35rem;
}

.nav-sidebar .nav-link {
  color: var(--bnh-sidebar-text) !important;
  border-radius: 9px;
  margin-bottom: 2px;
  padding: .55rem .75rem;
  transition: background .15s, color .15s;
}

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

.nav-sidebar .nav-link .nav-icon {
  font-size: .95rem !important;
  opacity: .9;
}

.nav-sidebar > .nav-item > .nav-link.active,
.nav-sidebar .nav-treeview .nav-link.active,
.nav-pills .nav-link.active {
  background: var(--bnh-primary) !important;
  color: #fff !important;
  box-shadow: 0 4px 12px -4px rgba(13, 148, 136, .6) !important;
}

.nav-sidebar .menu-open > .nav-link,
.nav-sidebar .menu-is-opening > .nav-link {
  background: rgba(255, 255, 255, .05) !important;
  color: #fff !important;
}

.nav-sidebar .nav-treeview {
  padding-left: 10px;
}

.nav-sidebar .nav-treeview .nav-link {
  font-size: .88rem;
}

.sidebar-mini.sidebar-collapse .main-sidebar:not(:hover) .brand-link .brand-text,
.sidebar-mini.sidebar-collapse .main-sidebar:not(:hover) .bnh-sidebar-user .bnh-user-meta {
  display: none;
}

.bnh-sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 8px;
  margin-bottom: 4px;
  border-bottom: 1px solid rgba(255, 255, 255, .06);
}

.bnh-sidebar-user .bnh-user-meta {
  color: #fff;
  font-weight: 600;
  line-height: 1.2;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.bnh-sidebar-user small {
  display: block;
  color: var(--bnh-sidebar-text);
  font-weight: 500;
}

/* ---------- cards ---------- */
.card {
  border: 1px solid var(--bnh-border);
  border-radius: var(--bnh-radius);
  box-shadow: var(--bnh-shadow);
}

.card > .card-header,
.card-header {
  background: transparent;
  border-bottom: 1px solid var(--bnh-border);
  padding: .9rem 1.15rem;
}

.card-header:first-child {
  border-radius: var(--bnh-radius) var(--bnh-radius) 0 0;
}

.card-title {
  font-weight: 650;
  font-size: 1rem;
}

.card-body {
  padding: 1.15rem;
}

/* coloured card headers become a slim accent instead of a full colour block */
.card-primary:not(.card-outline) > .card-header,
.card-info:not(.card-outline) > .card-header,
.card-dark:not(.card-outline) > .card-header,
.card-success:not(.card-outline) > .card-header {
  background: #fff;
  color: var(--bnh-text);
  border-top: 3px solid var(--bnh-primary);
}

.card-info:not(.card-outline) > .card-header {
  border-top-color: var(--bnh-accent);
}

.card-dark:not(.card-outline) > .card-header {
  border-top-color: #334155;
}

.card-primary:not(.card-outline) > .card-header .btn-tool,
.card-info:not(.card-outline) > .card-header .btn-tool,
.card-dark:not(.card-outline) > .card-header .btn-tool {
  color: var(--bnh-muted);
}

.card-primary.card-outline {
  border-top: 3px solid var(--bnh-primary);
}

/* ---------- buttons ---------- */
.btn {
  border-radius: var(--bnh-radius-sm);
  font-weight: 550;
  transition: background-color .15s, border-color .15s, box-shadow .15s, transform .05s;
}

.btn:active {
  transform: translateY(1px);
}

.btn-sm {
  border-radius: 7px;
}

.btn-primary,
.btn-primary:not(:disabled):not(.disabled):active {
  background: var(--bnh-primary);
  border-color: var(--bnh-primary);
}

.btn-primary:hover,
.btn-primary:focus {
  background: var(--bnh-primary-700);
  border-color: var(--bnh-primary-700);
}

.btn-primary:focus,
.btn:focus {
  box-shadow: 0 0 0 3px rgba(13, 148, 136, .25) !important;
}

.btn-outline-primary {
  color: var(--bnh-primary);
  border-color: var(--bnh-primary);
}

.btn-outline-primary:hover {
  background: var(--bnh-primary);
  border-color: var(--bnh-primary);
}

.btn-dark {
  background: #1e293b;
  border-color: #1e293b;
}

.btn-dark:hover {
  background: #0f172a;
  border-color: #0f172a;
}

.btn-tool {
  border-radius: 6px;
}

.bg-primary,
.badge-primary {
  background-color: var(--bnh-primary) !important;
}

.text-primary {
  color: var(--bnh-primary) !important;
}

/* ---------- forms ---------- */
.form-control,
.custom-select,
.select2-container--default .select2-selection--single {
  border-radius: var(--bnh-radius-sm);
  border-color: #d5dce6;
  min-height: 38px;
}

.form-control:focus,
.custom-select:focus {
  border-color: var(--bnh-primary-600);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, .15);
}

.form-control-sm {
  min-height: 31px;
}

label:not(.form-check-label):not(.custom-control-label) {
  font-weight: 600;
  font-size: .85rem;
  color: #334155;
  margin-bottom: .3rem;
}

.input-group-text {
  background: #f8fafc;
  border-color: #d5dce6;
}

.custom-control-input:checked ~ .custom-control-label::before {
  background-color: var(--bnh-primary);
  border-color: var(--bnh-primary);
}

/* ---------- tables ---------- */
.table {
  color: var(--bnh-text);
}

.table th,
.table td {
  vertical-align: middle;
  border-color: #edf1f6;
  padding: .65rem .75rem;
}

.table thead th {
  border-bottom: 1px solid var(--bnh-border);
  font-size: .74rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: #475569;
  white-space: nowrap;
}

/* many pages use <thead class="bg-dark">; keep them readable and calm */
.table thead.bg-dark,
.table thead.bg-dark th,
.table thead.bg-primary th,
.table thead.thead-dark th {
  background: #f1f5f9 !important;
  color: #475569 !important;
  border-color: var(--bnh-border) !important;
}

.table-bordered,
.table-bordered th,
.table-bordered td {
  border-color: #edf1f6;
}

.table-striped tbody tr:nth-of-type(odd) {
  background: #fafbfd;
}

.table-hover tbody tr:hover,
.table tbody tr:hover {
  background: var(--bnh-primary-50);
}

.table-responsive {
  border-radius: var(--bnh-radius-sm);
}

/* DataTables */
.dataTables_wrapper .dt-buttons .btn {
  background: #fff;
  color: #334155;
  border: 1px solid var(--bnh-border);
  font-size: .8rem;
  padding: .3rem .7rem;
}

.dataTables_wrapper .dt-buttons .btn:hover {
  background: var(--bnh-primary-50);
  color: var(--bnh-primary);
}

.dataTables_wrapper .dataTables_filter input {
  border-radius: 999px;
  padding-left: 12px;
}

.dataTables_info {
  color: var(--bnh-muted);
  font-size: .85rem;
}

/* pagination */
.pagination .page-link {
  border-radius: 8px !important;
  margin: 0 2px;
  border-color: var(--bnh-border);
  color: #334155;
}

.page-item.active .page-link {
  background: var(--bnh-primary);
  border-color: var(--bnh-primary);
}

/* ---------- stat tiles (AdminLTE small-box) ---------- */
.small-box {
  border-radius: var(--bnh-radius);
  box-shadow: var(--bnh-shadow);
  overflow: hidden;
  background-image: linear-gradient(135deg, rgba(255, 255, 255, .12), rgba(255, 255, 255, 0));
}

.small-box.bg-primary {
  background-color: var(--bnh-primary) !important;
}

.small-box > .small-box-footer {
  background: rgba(0, 0, 0, .12);
  font-size: .82rem;
}

.small-box .icon > i {
  opacity: .25;
}

/* ---------- modals, alerts, badges ---------- */
.modal-content {
  border: none;
  border-radius: 16px;
  box-shadow: var(--bnh-shadow-lg);
}

.modal-header {
  border-bottom: 1px solid var(--bnh-border);
  padding: 1rem 1.25rem;
}

.modal-footer {
  border-top: 1px solid var(--bnh-border);
}

.modal-title,
.modal-header h1 {
  font-weight: 650;
}

.alert {
  border-radius: var(--bnh-radius-sm);
}

.badge {
  border-radius: 999px;
  font-weight: 600;
  padding: .35em .7em;
}

/* Bootstrap 5 classes that slipped into a few views */
.fs-5 {
  font-size: 1.15rem !important;
}

.btn-close {
  background: none;
  border: 0;
  font-size: 1.4rem;
  line-height: 1;
  opacity: .5;
}

.btn-close::before {
  content: "\00d7";
}

/* SweetAlert */
.swal-modal {
  border-radius: 16px;
  font-family: var(--bnh-font);
}

.swal-button {
  border-radius: var(--bnh-radius-sm);
  background: var(--bnh-primary);
}

.swal-button:not([disabled]):hover {
  background: var(--bnh-primary-700);
}

.swal-button--cancel {
  background: #e2e8f0;
  color: #334155;
}

.swal-button--danger {
  background: var(--bnh-danger);
}

.swal-title {
  font-size: 1.25rem;
}

/* ---------- footer ---------- */
.main-footer {
  background: transparent;
  border-top: 1px solid var(--bnh-border);
  color: var(--bnh-muted);
  font-size: .82rem;
  padding: .8rem 1rem;
}

.main-footer a {
  color: var(--bnh-muted);
  font-weight: 600;
}

/* ---------- dashboard ---------- */
.bnh-hello {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 18px;
}

.bnh-hello h1 {
  font-size: 1.5rem;
  font-weight: 650;
  margin: 0;
  letter-spacing: -.01em;
}

.bnh-hello p {
  margin: 2px 0 0;
  color: var(--bnh-muted);
}

.bnh-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.bnh-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.bnh-kpi {
  background: var(--bnh-surface);
  border: 1px solid var(--bnh-border);
  border-radius: var(--bnh-radius);
  box-shadow: var(--bnh-shadow);
  padding: 16px 18px;
  display: flex;
  gap: 14px;
  align-items: center;
  color: inherit;
  transition: transform .15s, box-shadow .15s;
}

a.bnh-kpi:hover {
  color: inherit;
  transform: translateY(-2px);
  box-shadow: var(--bnh-shadow-lg);
}

.bnh-kpi .bnh-kpi-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 1.1rem;
  flex-shrink: 0;
  background: var(--bnh-primary-50);
  color: var(--bnh-primary);
}

.bnh-kpi .bnh-kpi-icon.is-blue {
  background: #eff6ff;
  color: var(--bnh-accent);
}

.bnh-kpi .bnh-kpi-icon.is-amber {
  background: #fffbeb;
  color: var(--bnh-warning);
}

.bnh-kpi .bnh-kpi-icon.is-violet {
  background: #f5f3ff;
  color: #7c3aed;
}

.bnh-kpi .bnh-kpi-icon.is-green {
  background: #f0fdf4;
  color: var(--bnh-success);
}

.bnh-kpi .bnh-kpi-value {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.bnh-kpi .bnh-kpi-label {
  color: var(--bnh-muted);
  font-size: .82rem;
  font-weight: 500;
}

.bnh-section-title {
  font-size: .78rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--bnh-muted);
  margin: 6px 0 10px;
}

.bnh-depts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}

.bnh-dept {
  background: var(--bnh-surface);
  border: 1px solid var(--bnh-border);
  border-radius: var(--bnh-radius);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--bnh-text);
  transition: border-color .15s, box-shadow .15s;
}

.bnh-dept:hover {
  color: var(--bnh-text);
  border-color: var(--bnh-primary-600);
  box-shadow: var(--bnh-shadow);
}

.bnh-dept .bnh-dept-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--bnh-primary-50);
  color: var(--bnh-primary);
  display: grid;
  place-items: center;
}

.bnh-dept strong {
  display: block;
  font-weight: 600;
}

.bnh-dept small {
  color: var(--bnh-muted);
}

.bnh-dept .fa-chevron-right {
  margin-left: auto;
  color: #cbd5e1;
  font-size: .8rem;
}

.bnh-chart-card .card-body {
  height: 290px;
}

.bnh-empty {
  text-align: center;
  color: var(--bnh-muted);
  padding: 30px 10px;
}

/* ---------- page loading bar ---------- */
#bnh-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0;
  background: linear-gradient(90deg, var(--bnh-primary-600), var(--bnh-accent));
  z-index: 3000;
  transition: width .25s ease, opacity .3s;
  opacity: 0;
}

#bnh-progress.is-active {
  opacity: 1;
}

/* ---------- print ---------- */
@media print {
  .main-sidebar,
  .main-header,
  .main-footer,
  .dt-buttons,
  .dataTables_filter,
  .pagination,
  .btn {
    display: none !important;
  }

  .content-wrapper {
    margin: 0 !important;
  }

  .card {
    box-shadow: none;
    border: none;
  }
}
