/* HIS application styles. Theme colours come from Bootstrap 5.3 CSS variables
   set by the layout from hospital/user settings (no rebuild needed). */
:root { --his-sidebar-width: 260px; --his-topbar-height: 56px; }

.his-body { min-height: 100vh; background: var(--bs-tertiary-bg); }
.his-topbar { min-height: var(--his-topbar-height); z-index: 1030; }
.his-logo { height: 32px; width: auto; }
[data-bs-theme="light"] .his-logo-dark, [data-bs-theme="dark"] .his-logo-light { display: none; }
.his-brand-name { max-width: 16rem; }
.his-user-name { max-width: 12rem; }
.his-avatar { width: 2rem; height: 2rem; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--his-primary); color: #fff; font-weight: 600; font-size: .9rem; }

.his-wrapper { display: flex; min-height: calc(100vh - var(--his-topbar-height)); }
.his-main { flex: 1 1 auto; min-width: 0; }

@media (min-width: 992px) {
  .his-sidebar { width: var(--his-sidebar-width); flex: 0 0 var(--his-sidebar-width); position: sticky; top: var(--his-topbar-height); height: calc(100vh - var(--his-topbar-height)); overflow-y: auto; }
  .sidebar-collapsed .his-sidebar { width: 64px; flex-basis: 64px; }
  .sidebar-collapsed .his-sidebar .nav-link span, .sidebar-collapsed .his-sidebar .his-menu-heading, .sidebar-collapsed .his-sidebar .his-chevron, .sidebar-collapsed .his-sidebar .his-pin, .sidebar-collapsed .his-sidebar .collapse { display: none !important; }
}
.his-sidebar .nav-link { color: var(--bs-body-color); border-radius: .375rem; padding: .45rem .75rem; display: flex; align-items: center; gap: .6rem; }
.his-sidebar .nav-link:hover { background: var(--bs-secondary-bg); }
.his-sidebar .nav-link.active { background: rgba(var(--bs-primary-rgb), .12); color: var(--his-primary); font-weight: 600; }
.his-sidebar .nav-link .bi { font-size: 1.05rem; width: 1.25rem; text-align: center; }
.his-sidebar button.nav-link[aria-expanded="true"] .his-chevron { transform: rotate(180deg); }
.his-menu-heading { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--bs-secondary-color); padding: .5rem .75rem .25rem; }
.his-pin { opacity: 0; }
.nav-item:hover > .his-pin, .his-pin:focus { opacity: 1; }

.card { border-color: var(--bs-border-color-translucent); }
.table > :not(caption) > * > * { vertical-align: middle; }
.dt-container .dt-search input { min-width: 14rem; }
.his-filter-bar .form-control, .his-filter-bar .form-select { min-width: 10rem; }

/* Permission tree */
.perm-module { border-left: 3px solid rgba(var(--bs-primary-rgb), .5); }
.perm-block { border: 1px solid var(--bs-border-color-translucent); border-radius: .5rem; }
.perm-row { padding: .35rem .5rem; border-radius: .375rem; }
.perm-row:hover { background: var(--bs-secondary-bg); }
.perm-key { font-family: var(--bs-font-monospace); font-size: .8rem; color: var(--bs-secondary-color); }

/* Auth pages */
.his-auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bs-tertiary-bg); padding: 1rem; }
.his-auth-main { width: 100%; max-width: 440px; }
.his-auth-logo { max-height: 72px; max-width: 220px; }
.his-auth-mark { font-size: 2.5rem; color: var(--his-primary); }
/* Demo mode (Config\Demo) */
.his-demo-banner { background: #ffe066; color: #3d3000; font-size: .8rem; font-weight: 600; text-align: center; padding: .2rem .75rem; line-height: 1.3; }
.his-auth.his-demo { position: relative; padding-top: 2.75rem; }
.his-auth > .his-demo-banner { position: absolute; top: 0; left: 0; right: 0; }
/* Login with the test-account directory (demo mode): form on the right, directory on the left; the directory
   fits the screen and its two panes (departments | accounts) scroll on their own. */
.his-auth-main.his-auth-wide { max-width: 1240px; }
.his-auth-split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 420px); gap: 1.5rem; align-items: center; }
.his-auth-split-aside { order: 1; min-width: 0; }
.his-auth-split-form { order: 2; }
.his-dir { height: clamp(28rem, calc(100vh - 5.5rem), 56rem); display: flex; flex-direction: column; overflow: hidden; }
.his-dir-head { padding: 1rem 1.25rem .85rem; border-bottom: 1px solid var(--bs-border-color); }
.his-dir-search-icon { position: absolute; left: .85rem; top: 50%; transform: translateY(-50%); color: var(--bs-secondary-color); pointer-events: none; }
.his-dir-body { flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: 14rem minmax(0, 1fr); }
.his-dir-index { position: relative; overflow-y: auto; padding: .5rem; border-right: 1px solid var(--bs-border-color); background: var(--bs-tertiary-bg); }
.his-dir-index-link { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .35rem .6rem; border-radius: .375rem; color: var(--bs-body-color); text-decoration: none; font-size: .875rem; }
.his-dir-index-link:hover { background: var(--bs-secondary-bg); }
.his-dir-index-link.active { background: color-mix(in srgb, var(--his-primary, #0B6E4F) 12%, transparent); color: var(--his-primary, #0B6E4F); font-weight: 600; }
.his-dir-list { position: relative; overflow-y: auto; min-height: 0; overscroll-behavior: contain; }
.his-dir-group-head { position: sticky; top: 0; z-index: 1; margin: 0; padding: .5rem 1.25rem; font-size: .875rem; font-weight: 600; background: var(--bs-body-bg); border-bottom: 1px solid var(--bs-border-color); }
.his-dir-item { display: flex; align-items: center; gap: .85rem; width: 100%; padding: .6rem 1.25rem; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--bs-border-color-translucent); border-left: 3px solid transparent; color: inherit; }
.his-dir-item:hover { background: var(--bs-secondary-bg); }
.his-dir-item:focus-visible { outline: 2px solid var(--his-primary, #0B6E4F); outline-offset: -2px; }
.his-dir-item.active { background: color-mix(in srgb, var(--his-primary, #0B6E4F) 9%, transparent); border-left-color: var(--his-primary, #0B6E4F); }
.his-dir-slot { flex: 0 0 3.75rem; text-align: center; font-size: .75rem; font-weight: 600; padding: .15rem 0; border-radius: 1rem; border: 1px solid var(--bs-border-color); color: var(--bs-secondary-color); }
.his-dir-slot-head { background: var(--his-primary, #0B6E4F); border-color: var(--his-primary, #0B6E4F); color: #fff; }
.his-dir-who { display: flex; flex-direction: column; min-width: 0; flex: 1 1 auto; }
.his-dir-user { overflow-wrap: anywhere; }
.his-dir-roles { font-size: .8rem; color: var(--bs-secondary-color); }
.his-dir-tick { color: var(--his-primary, #0B6E4F); visibility: hidden; }
.his-dir-item.active .his-dir-tick { visibility: visible; }
.his-dir-filled { padding: .5rem .75rem; border-radius: .375rem; background: color-mix(in srgb, var(--his-primary, #0B6E4F) 9%, transparent); overflow-wrap: anywhere; }
@media (prefers-reduced-motion: no-preference) { .his-dir-list { scroll-behavior: smooth; } }
@media (max-width: 991.98px) {
  .his-auth-split { grid-template-columns: 1fr; }
  .his-auth-split-form { order: 1; }
  .his-auth-split-aside { order: 2; }
  .his-dir { height: 70vh; }
  .his-dir-body { grid-template-columns: 1fr; }
  .his-dir-search, .his-dir-jump { flex: 1 1 100%; }
}
.pw-checklist li { list-style: none; }
.pw-checklist li::before { content: "\2717"; color: var(--bs-danger); margin-right: .4rem; }
.pw-checklist li.ok::before { content: "\2713"; color: var(--bs-success); }
.recovery-codes { font-family: var(--bs-font-monospace); font-size: 1.05rem; letter-spacing: .05em; }

.his-patient-banner { border-left: 4px solid var(--his-primary); }
.swal2-popup { font-size: 1rem; }
.widget-value { font-size: 1.75rem; font-weight: 600; }

/* Top bar counters and notification bell (Phase 1) */
.his-count { font-size: .65rem; }
.his-bell-menu { width: 22rem; max-width: 92vw; }
.his-bell-menu [data-bell-list] { max-height: 60vh; overflow-y: auto; }

/* Phase 2: the top bar must never push the page wider than a phone screen */
.his-topbar { flex-wrap: nowrap; }
.his-topbar .navbar-brand { min-width: 0; flex: 0 1 auto; overflow: hidden; }
.his-topbar > .ms-auto { flex: 0 0 auto; }
@media (max-width: 575.98px) {
  .his-topbar .navbar-brand { margin-right: .25rem !important; }
  .his-brand-name { max-width: 34vw; }
  .his-topbar .btn-link { padding-left: .35rem; padding-right: .35rem; }
}

/* System health banner and page */
.his-health-banner { font-size: .85rem; font-weight: 600; text-align: center; padding: .35rem .75rem; line-height: 1.35; }
.his-health-banner a { color: inherit; text-decoration: underline; }
.his-health-banner-critical { background: #b02a37; color: #fff; animation: his-health-pulse 2s ease-in-out infinite; }
.his-health-banner-ack { background: #ffda6a; color: #3d3000; }
@keyframes his-health-pulse { 0%, 100% { background: #b02a37; } 50% { background: #dc3545; } }
@media (prefers-reduced-motion: reduce) { .his-health-banner-critical { animation: none; } }
.his-health-card { border-left: .3rem solid var(--bs-secondary-border-subtle); }
.his-health-card.st-ok { border-left-color: var(--bs-success); }
.his-health-card.st-warning { border-left-color: var(--bs-warning); }
.his-health-card.st-critical { border-left-color: var(--bs-danger); }
.his-health-overall { font-size: 1.35rem; font-weight: 600; }
.his-health-dot { display: inline-block; width: .7rem; height: .7rem; border-radius: 50%; background: var(--bs-secondary); vertical-align: baseline; }
.his-health-dot.st-ok { background: var(--bs-success); }
.his-health-dot.st-warning { background: var(--bs-warning); }
.his-health-dot.st-critical { background: var(--bs-danger); }
.his-health-details { font-size: .8rem; color: var(--bs-secondary-color); margin: .35rem 0 0; padding-left: 1rem; }
.his-toast-stack { position: fixed; right: 1rem; bottom: 1rem; z-index: 1090; max-width: 22rem; }
