/* =====================================================================
   ICSR Case Management System — Brand Theme
   Palette: Deep Teal (trust/clinical) + Gold (compliance/attention) + Coral (alerts)
   ===================================================================== */

:root {
  --brand-teal:        #0B4F4A;
  --brand-teal-dark:   #073C38;
  --brand-teal-light:  #E8F3F1;
  --brand-mint:        #D8ECE8;
  --brand-gold:        #C9922E;
  --brand-gold-light:  #FBF1DF;
  --brand-coral:       #D96C4B;
  --brand-coral-light: #FBEAE4;
  --brand-green:       #2E8B6E;
  --brand-green-light: #E4F3EE;
  --argus-steel:       #0B4F4A;
  --argus-steel-dark:  #073C38;
  --ink:               #1F2A28;
  --gray:              #5C6C69;
  --gray-light:        #8FA19E;
  --bg-app:            #F5F7F6;
  --card-bg:           #FFFFFF;
  --radius-lg: 10px;
  --radius-md: 8px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 3px rgba(11,79,74,0.08), 0 1px 2px rgba(11,79,74,0.06);
  --shadow-md: 0 4px 14px rgba(11,79,74,0.10), 0 2px 4px rgba(11,79,74,0.06);
  --shadow-lg: 0 10px 30px rgba(11,79,74,0.14);
}

/* ---------- Base ---------- */
body {
  background-color: var(--bg-app);
  font-family: 'Inter', 'Calibri', 'Segoe UI', sans-serif;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, h5, h6, .brand-font {
  font-family: 'Poppins', 'Calibri', 'Segoe UI', sans-serif;
  font-weight: 600;
  color: var(--ink);
}
a { color: var(--brand-teal); }
a:hover { color: var(--brand-teal-dark); }

::selection { background: var(--brand-gold-light); color: var(--brand-teal-dark); }

/* subtle page entrance */
.container-fluid.py-4 { animation: fadeInUp .35s ease both; }
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Navbar ---------- */
.navbar {
  background: linear-gradient(135deg, var(--brand-teal) 0%, var(--brand-teal-dark) 100%) !important;
  box-shadow: 0 2px 12px rgba(0,0,0,0.18);
  padding-top: .65rem;
  padding-bottom: .65rem;
}
.navbar-brand {
  font-family: 'Poppins', sans-serif;
  font-weight: 700;
  letter-spacing: .01em;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.navbar .nav-link {
  font-size: 0.88rem;
  font-weight: 500;
  color: rgba(255,255,255,0.82) !important;
  padding: .5rem .75rem;
  border-radius: var(--radius-sm);
  transition: background .15s ease, color .15s ease;
  position: relative;
}
.navbar .nav-link:hover {
  color: #fff !important;
  background: rgba(255,255,255,0.08);
}
.navbar .nav-link i { margin-right: .3rem; }
.navbar .badge { font-weight: 500; font-size: .68rem; vertical-align: middle; }

/* ---------- Cards ---------- */
.card {
  border: 1px solid #D3DCE6;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  background: var(--card-bg);
  transition: box-shadow .2s ease;
}
.card:hover { box-shadow: var(--shadow-md); }

/* Argus-style solid section header bar — the first h5/h6 directly inside a
   card body becomes a full-width colored strip with white text, echoing
   Argus Safety's "General Information" / "Reporter Information" bars. */
.card.p-3 > h5:first-child, .card.p-3 > h6:first-child,
.card > .card-body > h5:first-child, .card > .card-body > h6:first-child {
  background: linear-gradient(90deg, var(--argus-steel) 0%, var(--brand-teal) 100%);
  color: #fff;
  margin: -1rem -1rem 1rem -1rem;
  padding: .55rem 1rem;
  border-radius: calc(var(--radius-md) - 1px) calc(var(--radius-md) - 1px) 0 0;
  font-size: .82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.card.p-3 > h5:first-child i, .card.p-3 > h6:first-child i { margin-right: .4rem; }

/* ---------- Buttons ---------- */
.btn {
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: .875rem;
  padding: .45rem 1.1rem;
  transition: transform .12s ease, box-shadow .12s ease, background .15s ease;
}
.btn-sm { padding: .3rem .8rem; font-size: .8rem; }
.btn-primary {
  background: var(--argus-steel);
  border-color: var(--argus-steel-dark);
}
.btn-primary:hover, .btn-primary:focus {
  background: var(--brand-teal-dark);
  border-color: var(--brand-teal-dark);
  box-shadow: 0 4px 12px rgba(31,63,99,0.28);
  transform: translateY(-1px);
}
.btn-outline-primary { color: var(--argus-steel); border-color: var(--argus-steel); }
.btn-outline-primary:hover { background: var(--argus-steel); border-color: var(--argus-steel); transform: translateY(-1px); }
.btn-success { background: var(--brand-green); border-color: var(--brand-green); }
.btn-success:hover { background: #256f57; border-color: #256f57; transform: translateY(-1px); }
.btn-outline-success { color: var(--brand-green); border-color: var(--brand-green); }
.btn-outline-success:hover { background: var(--brand-green); border-color: var(--brand-green); }
.btn-outline-danger:hover, .btn-danger:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(.98); }

/* ---------- Badges ---------- */
.badge { border-radius: 4px; font-weight: 500; font-size: .72rem; padding: .4em .75em; letter-spacing: .01em; }

/* ---------- Tables ---------- */
/* Dense, gridded rows — closer to Argus's data-grid tables than the airy
   spacing of a typical modern admin theme. */
.table { margin-bottom: 0; border: 1px solid #DCE3EC; }
.table thead th {
  background-color: var(--argus-steel);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  border-bottom: none;
  border-right: 1px solid rgba(255,255,255,0.15);
  padding: .6rem .85rem;
}
.table td { padding: .55rem .85rem; vertical-align: middle; border-color: #E3E9F1; font-size: .875rem; }
.table-hover tbody tr:hover { background-color: var(--brand-teal-light); }
.table-sm td, .table-sm th { padding: .5rem .7rem; }
.table-striped tbody tr:nth-of-type(odd) { background-color: #F7F9FC; }

/* ---------- Forms ---------- */
.form-control, .form-select {
  border-radius: var(--radius-sm);
  border-color: #C8D2DE;
  font-size: .875rem;
  padding: .5rem .75rem;
}
.form-control:focus, .form-select:focus {
  border-color: var(--argus-steel);
  box-shadow: 0 0 0 .2rem rgba(74,111,165,0.15);
}
.form-label { font-size: .8rem; font-weight: 600; color: var(--gray); margin-bottom: .3rem; }
.form-control-sm, .form-select-sm { border-radius: 5px; }

/* ---------- Nav tabs ---------- */
/* Argus's tab strip is a solid steel-blue bar of rectangular tabs, with the
   active tab lifted to white — this echoes that rather than the soft
   underline-tab style of a typical Bootstrap theme. */
.nav-tabs {
  border-bottom: 2px solid var(--argus-steel-dark);
  background: linear-gradient(180deg, #EAF0F7 0%, #DCE6F1 100%);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  padding: .35rem .35rem 0;
  gap: .2rem;
}
.nav-tabs .nav-link {
  border: 1px solid transparent;
  border-radius: 4px 4px 0 0;
  color: var(--argus-steel-dark);
  font-weight: 600;
  font-size: .8rem;
  padding: .55rem 1rem;
}
.nav-tabs .nav-link:hover { background: rgba(255,255,255,0.6); color: var(--brand-teal-dark); border-color: transparent; }
.nav-tabs .nav-link.active {
  color: #fff;
  background: var(--argus-steel);
  border: 1px solid var(--argus-steel-dark);
  border-bottom: 2px solid var(--argus-steel);
  margin-bottom: -2px;
}

/* ---------- Stat tiles (dashboard, backups, etc.) ---------- */
.stat-tile {
  display: flex;
  align-items: center;
  gap: .9rem;
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 1.1rem 1.2rem;
  height: 100%;
  transition: box-shadow .2s ease, transform .2s ease;
}
.stat-tile:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.stat-tile-icon {
  width: 48px; height: 48px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 1.25rem; flex-shrink: 0;
}
.stat-tile-number { font-family: 'Poppins', sans-serif; font-size: 1.5rem; font-weight: 700; color: var(--ink); line-height: 1.15; }
.stat-tile-label { font-size: .75rem; color: var(--gray); font-weight: 500; }

/* legacy stat-card (kept for compatibility) */
.stat-card { border-radius: var(--radius-lg); color: #fff; box-shadow: var(--shadow-md); }
.stat-card .stat-number { font-size: 2rem; font-weight: 700; font-family: 'Poppins', sans-serif; }

/* ---------- Workflow stepper ---------- */
.workflow-stepper { display: flex; align-items: center; gap: 0; margin: 1rem 0 .5rem; }
.workflow-stepper .step-wrap { flex: 1; display: flex; align-items: center; }
.workflow-stepper .step {
  flex: 1; text-align: center; padding: .55rem .4rem;
  font-size: .74rem; font-weight: 600; border-radius: var(--radius-sm);
  background: #EEF2F1; color: var(--gray-light);
  border: 2px solid transparent;
  transition: all .2s ease;
}
.workflow-stepper .step.done { background: var(--brand-green-light); color: var(--brand-green); }
.workflow-stepper .step.active { background: var(--brand-teal); color: #fff; border-color: var(--brand-gold); box-shadow: 0 3px 10px rgba(11,79,74,0.3); }
.workflow-stepper .connector { width: 14px; height: 2px; background: #DDE5E3; flex-shrink: 0; }

/* ---------- Progress bars ---------- */
.progress { border-radius: 999px; background-color: #EEF2F1; height: 18px; }
.progress-bar { background-color: var(--brand-teal); font-size: .72rem; font-weight: 600; }

/* ---------- Alerts / flash messages ---------- */
.alert { border: none; border-radius: var(--radius-md); font-size: .875rem; }
.alert-success { background: var(--brand-green-light); color: #1E5F49; }
.alert-danger { background: var(--brand-coral-light); color: #A6431F; }
.alert-warning { background: var(--brand-gold-light); color: #8A6216; }
.alert-info { background: var(--brand-teal-light); color: var(--brand-teal-dark); }

/* ---------- List groups ---------- */
.list-group-item { border-color: #EEF2F1; font-size: .875rem; }

/* ---------- Login page ---------- */
.login-wrapper {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--brand-teal-dark) 0%, var(--brand-teal) 60%, #0F5F59 100%);
  position: relative; overflow: hidden;
}
.login-wrapper::before, .login-wrapper::after {
  content: ""; position: absolute; border-radius: 50%;
  background: rgba(255,255,255,0.05);
}
.login-wrapper::before { width: 420px; height: 420px; top: -160px; right: -120px; }
.login-wrapper::after { width: 300px; height: 300px; bottom: -140px; left: -80px; background: rgba(201,146,46,0.12); }
.login-card {
  max-width: 420px; width: 100%;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  position: relative; z-index: 1;
  border: none;
}
.login-card .card-body { padding: 2.5rem 2.25rem; }
.login-brand-icon {
  width: 56px; height: 56px; border-radius: 16px;
  background: #fff; display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 1.5rem; margin: 0 auto .5rem;
  padding: 6px; box-shadow: var(--shadow-sm); border: 1px solid #EEF2F1;
}
.login-brand-icon img { width: 100%; height: 100%; object-fit: contain; }

/* ---------- Footer ---------- */
footer { color: var(--gray-light); font-size: .8rem; }

/* ---------- Misc ---------- */
.text-brand { color: var(--brand-teal) !important; }
.bg-brand-light { background: var(--brand-teal-light) !important; }
code { color: var(--brand-coral); background: var(--brand-coral-light); padding: .1em .4em; border-radius: 5px; font-size: .85em; }
pre { border-radius: var(--radius-sm); }

/* =====================================================================
   APP SHELL — sidebar + topbar layout
   ===================================================================== */

body { margin: 0; }

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

/* ---------- Sidebar ---------- */
.sidebar {
  width: 250px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--brand-teal-dark) 0%, var(--brand-teal) 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 1040;
}
.sidebar-brand {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.3rem 1.1rem 1rem;
}
.sidebar-brand-link { display: flex; align-items: center; gap: .65rem; text-decoration: none; }
.sidebar-brand-icon {
  width: 38px; height: 38px; border-radius: 11px; background: #fff;
  display: flex; align-items: center; justify-content: center; color: var(--brand-gold); font-size: 1.15rem; flex-shrink: 0;
  padding: 4px; box-shadow: 0 2px 6px rgba(0,0,0,0.18);
}
.sidebar-brand-icon img { width: 100%; height: 100%; object-fit: contain; }
.sidebar-brand-text { font-family: 'Poppins', sans-serif; font-weight: 700; color: #fff; font-size: .95rem; line-height: 1.25; }
.sidebar-brand-text small { font-family: 'Inter', sans-serif; font-weight: 500; color: rgba(255,255,255,0.55); font-size: .68rem; letter-spacing: .03em; text-transform: uppercase; }
.sidebar-close { background: none; border: none; color: rgba(255,255,255,0.7); font-size: 1.1rem; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: .5rem .75rem; }
.sidebar-section-label {
  font-size: .66rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em;
  color: rgba(255,255,255,0.38); padding: 1rem .6rem .4rem;
}
.sidebar-link {
  display: flex; align-items: center; gap: .7rem;
  padding: .6rem .7rem; margin-bottom: .15rem;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,0.78);
  font-size: .87rem; font-weight: 500;
  text-decoration: none;
  transition: background .15s ease, color .15s ease;
}
.sidebar-link i { font-size: 1.05rem; width: 20px; text-align: center; flex-shrink: 0; }
.sidebar-link:hover { background: rgba(255,255,255,0.08); color: #fff; }
.sidebar-link.active { background: rgba(255,255,255,0.14); color: #fff; font-weight: 600; box-shadow: inset 3px 0 0 var(--brand-gold); }
.sidebar-pill {
  margin-left: auto; background: var(--brand-coral); color: #fff; font-size: .68rem; font-weight: 700;
  padding: .1em .5em; border-radius: 999px; line-height: 1.4;
}
.sidebar-subnav { padding-left: .5rem; border-left: 2px solid rgba(255,255,255,0.08); margin: 0 0 .3rem .95rem; }
.sidebar-sublink { padding-top: .48rem; padding-bottom: .48rem; font-size: .82rem; }
.sidebar-stage-dot { font-size: .5rem !important; width: 20px; }
.sidebar-pill-muted { background: rgba(255,255,255,0.14); color: rgba(255,255,255,0.85); }

.sidebar-user {
  display: flex; align-items: center; gap: .65rem;
  padding: 1rem 1.1rem; border-top: 1px solid rgba(255,255,255,0.1);
}
.sidebar-user-avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--brand-gold);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-family: 'Poppins', sans-serif; font-weight: 700; font-size: .85rem; flex-shrink: 0;
}
.sidebar-user-info { min-width: 0; flex: 1; }
.sidebar-user-name { font-size: .82rem; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: .7rem; color: rgba(255,255,255,0.55); }
.sidebar-logout { color: rgba(255,255,255,0.6); font-size: 1.05rem; flex-shrink: 0; }
.sidebar-logout:hover { color: #fff; }

.sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 1035; }

/* ---------- Main / Topbar ---------- */
.main-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; gap: 1rem;
  background: var(--card-bg);
  border-bottom: 1px solid #EAEFEE;
  padding: .8rem 1.5rem;
  position: sticky; top: 0; z-index: 1020;
}
.topbar-toggle { background: none; border: none; font-size: 1.4rem; color: var(--ink); padding: 0; }
.topbar-title h1 { font-size: 1.15rem; font-weight: 600; margin: 0; color: var(--ink); white-space: nowrap; }
.topbar-search {
  flex: 1; max-width: 380px; align-items: center; gap: .5rem;
  background: var(--bg-app); border-radius: 999px; padding: .45rem 1rem;
  color: var(--gray-light);
}
.topbar-search input { border: none; background: none; outline: none; font-size: .85rem; width: 100%; color: var(--ink); }
.topbar-actions { display: flex; align-items: center; gap: .6rem; margin-left: auto; }

.topbar-icon-btn {
  position: relative; width: 38px; height: 38px; border-radius: 50%;
  background: var(--bg-app); border: none; color: var(--gray);
  display: flex; align-items: center; justify-content: center; font-size: 1.05rem;
}
.topbar-icon-btn:hover { background: var(--brand-teal-light); color: var(--brand-teal); }
.topbar-badge {
  position: absolute; top: -2px; right: -2px; background: var(--brand-coral); color: #fff;
  font-size: .62rem; font-weight: 700; border-radius: 999px; padding: .05em .38em; min-width: 16px; line-height: 1.4;
  border: 2px solid #fff;
}
.topbar-user-btn {
  display: flex; align-items: center; gap: .5rem;
  background: none; border: none; padding: .3rem .5rem; border-radius: 999px;
  font-size: .85rem; font-weight: 500; color: var(--ink);
}
.topbar-user-btn:hover { background: var(--bg-app); }
.topbar-avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--brand-teal);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-family: 'Poppins', sans-serif; font-weight: 700; font-size: .78rem;
}

.notif-menu { width: 320px; padding: 0; border: none; border-radius: var(--radius-md); box-shadow: var(--shadow-lg); overflow: hidden; }
.notif-menu-header { padding: .8rem 1rem .5rem; font-size: .8rem; font-weight: 700; color: var(--ink); }
.notif-item { display: flex; align-items: flex-start; gap: .6rem; padding: .6rem 1rem; text-decoration: none; border-top: 1px solid #F0F2F1; }
.notif-item:hover { background: var(--brand-teal-light); }
.notif-item-title { font-size: .82rem; font-weight: 600; color: var(--ink); }
.notif-item-sub { font-size: .72rem; color: var(--gray); }
.notif-menu-footer { display: block; text-align: center; padding: .6rem; font-size: .78rem; font-weight: 600; color: var(--brand-teal); border-top: 1px solid #F0F2F1; text-decoration: none; }
.notif-menu-footer:hover { background: var(--brand-teal-light); }
.notif-empty { padding: 1rem; text-align: center; font-size: .82rem; color: var(--gray); }

.content-area { flex: 1; padding: 1.5rem; animation: fadeInUp .3s ease both; }
.app-footer { color: var(--gray-light); font-size: .78rem; text-align: center; padding: 1rem; }
.topbar-location-badge {
  display: inline-flex; align-items: center; gap: .3rem;
  color: #fff; font-size: .68rem; font-weight: 600; letter-spacing: .02em;
  padding: .18rem .55rem; border-radius: 999px; margin-left: .6rem; vertical-align: middle;
}
/* Transmit panel — a plain in-page dropdown (not a Bootstrap modal), so there's no
   full-screen backdrop that can get stuck and block clicks on the rest of the page. */
.transmit-panel {
  background: #fff; border: 1px solid var(--border-color, #E2E8E6); border-radius: var(--radius-md, 10px);
  box-shadow: var(--shadow-md, 0 8px 24px rgba(0,0,0,.08));
  padding: 1rem; max-width: 420px;
}
.transmit-stage-options .form-check { padding-left: 1.75em; margin-bottom: .25rem; }
.transmit-stage-options .form-check-input { cursor: pointer; }
.transmit-stage-options .form-check-label { cursor: pointer; }

/* ---------- Responsive ---------- */
@media (max-width: 991.98px) {
  .sidebar {
    position: fixed; left: 0; top: 0; height: 100vh;
    transform: translateX(-100%);
    transition: transform .25s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop.show { display: block; }
  .topbar-title h1 { font-size: 1rem; }
}
@media (max-width: 575.98px) {
  .topbar { padding: .7rem 1rem; gap: .6rem; }
  .content-area { padding: 1rem; }
}

/* ---------- Activity feed (dashboard) ---------- */
.activity-feed { display: flex; flex-direction: column; gap: .1rem; }
.activity-item { display: flex; align-items: flex-start; gap: .65rem; padding: .55rem 0; border-bottom: 1px solid #F0F2F1; }
.activity-item:last-child { border-bottom: none; }
.activity-icon {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; color: #fff; font-size: .8rem;
}
.activity-body { min-width: 0; }
.activity-text { font-size: .8rem; color: var(--ink); line-height: 1.3; }
.activity-text strong { font-weight: 600; }
.activity-time { font-size: .7rem; color: var(--gray-light); }

/* =====================================================================
   ANIMATION SYSTEM
   ===================================================================== */

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes scaleIn { from { opacity: 0; transform: scale(.95); } to { opacity: 1; transform: scale(1); } }
@keyframes slideInLeft { from { opacity: 0; transform: translateX(-14px); } to { opacity: 1; transform: translateX(0); } }
@keyframes shimmer { 0% { background-position: -300px 0; } 100% { background-position: 300px 0; } }
@keyframes pulseRing {
  0%   { box-shadow: 0 0 0 0 rgba(217,108,75,0.45); }
  70%  { box-shadow: 0 0 0 7px rgba(217,108,75,0); }
  100% { box-shadow: 0 0 0 0 rgba(217,108,75,0); }
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Respect reduced-motion preference */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

/* Sidebar entrance + link stagger */
.sidebar-link { animation: slideInLeft .35s ease both; }
.sidebar-nav .sidebar-link:nth-child(1) { animation-delay: .02s; }
.sidebar-nav .sidebar-link:nth-child(2) { animation-delay: .05s; }
.sidebar-nav .sidebar-link:nth-child(3) { animation-delay: .08s; }
.sidebar-nav .sidebar-link:nth-child(4) { animation-delay: .11s; }
.sidebar-nav .sidebar-link:nth-child(5) { animation-delay: .14s; }
.sidebar-nav .sidebar-link:nth-child(6) { animation-delay: .17s; }

/* Content + card entrance stagger */
.content-area { animation: fadeIn .3s ease both; }
.content-area > *:not(.modal)  { animation: fadeInUp .4s cubic-bezier(.2,.8,.2,1) both; }
.content-area > *:not(.modal):nth-child(1) { animation-delay: .02s; }
.content-area > *:not(.modal):nth-child(2) { animation-delay: .07s; }
.content-area > *:not(.modal):nth-child(3) { animation-delay: .12s; }
.content-area > *:not(.modal):nth-child(4) { animation-delay: .17s; }
.content-area > *:not(.modal):nth-child(5) { animation-delay: .22s; }
/* Belt-and-suspenders: never let a transform-based entrance animation apply to the modal wrapper
   itself or any of its ancestors' completed-transform state trap it — modals must stay positioned
   relative to the viewport. (Scoped to .modal only, not its descendants, so things like the
   submit-button spinner inside a modal still animate normally.) */
.modal { animation: none !important; }

.stat-tile { animation: scaleIn .4s cubic-bezier(.2,.8,.2,1) both; }
.row.g-3 .col-md-3:nth-child(1) .stat-tile,
.row.g-3 .col-md-3:nth-child(1) { animation-delay: .04s; }
.row.g-3 .col-md-3:nth-child(2) .stat-tile,
.row.g-3 .col-md-3:nth-child(2) { animation-delay: .1s; }
.row.g-3 .col-md-3:nth-child(3) .stat-tile,
.row.g-3 .col-md-3:nth-child(3) { animation-delay: .16s; }
.row.g-3 .col-md-3:nth-child(4) .stat-tile,
.row.g-3 .col-md-3:nth-child(4) { animation-delay: .22s; }

.activity-item, .notif-item { animation: fadeIn .35s ease both; }
.activity-item:nth-child(1), .notif-item:nth-child(1) { animation-delay: .02s; }
.activity-item:nth-child(2), .notif-item:nth-child(2) { animation-delay: .06s; }
.activity-item:nth-child(3), .notif-item:nth-child(3) { animation-delay: .10s; }
.activity-item:nth-child(4), .notif-item:nth-child(4) { animation-delay: .14s; }
.activity-item:nth-child(5), .notif-item:nth-child(5) { animation-delay: .18s; }

/* Table row entrance (subtle, first page-load only via .table-animate helper class) */
.table-hover tbody tr { transition: background-color .12s ease, transform .12s ease; }
.table-hover tbody tr:hover { transform: translateX(2px); }

/* Dropdown menus: smoother pop */
.dropdown-menu {
  border: none; border-radius: var(--radius-md); box-shadow: var(--shadow-lg);
  animation: scaleIn .16s cubic-bezier(.2,.8,.2,1) both;
  transform-origin: top right;
}

/* Buttons: subtle ripple-like press + shine on primary hover */
.btn { position: relative; overflow: hidden; }
.btn-primary::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(120deg, transparent 30%, rgba(255,255,255,0.16) 50%, transparent 70%);
  transform: translateX(-100%);
  transition: transform .5s ease;
}
.btn-primary:hover::after { transform: translateX(100%); }

/* Icon buttons pop on hover */
.topbar-icon-btn, .sidebar-logout, .sidebar-close { transition: transform .15s ease, background .15s ease, color .15s ease; }
.topbar-icon-btn:hover { transform: translateY(-1px); }
.topbar-badge { animation: pulseRing 2s infinite; }

/* Stat tile icon micro-interaction */
.stat-tile-icon { transition: transform .25s cubic-bezier(.34,1.56,.64,1); }
.stat-tile:hover .stat-tile-icon { transform: scale(1.08) rotate(-4deg); }

/* Workflow stepper: animated fill */
.workflow-stepper .step { transition: background .3s ease, color .3s ease, box-shadow .3s ease, transform .2s ease; }
.workflow-stepper .step.active { animation: scaleIn .3s ease both; }

/* Progress bars animate width */
.progress-bar { transition: width .6s cubic-bezier(.2,.8,.2,1); }

/* Skeleton loader (optional utility, e.g. for async-loading blocks) */
.skeleton {
  background: linear-gradient(90deg, #EEF2F1 25%, #F7F9F8 37%, #EEF2F1 63%);
  background-size: 400px 100%;
  animation: shimmer 1.4s ease infinite;
  border-radius: var(--radius-sm);
}

/* Spinner for loading buttons */
.btn-spinner {
  display: inline-block; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.4); border-top-color: #fff;
  animation: spin .6s linear infinite; margin-right: .4rem; vertical-align: -2px;
}

/* Chart card fade-in (canvas parents) */
canvas { animation: fadeIn .5s ease .1s both; }

/* Login card entrance */
.login-card { animation: scaleIn .45s cubic-bezier(.2,.8,.2,1) both; }
.login-brand-icon { animation: scaleIn .5s cubic-bezier(.34,1.56,.64,1) .1s both; }

/* =====================================================================
   FULL RESPONSIVE / ADAPTIVE LAYER
   ===================================================================== */

/* ---------- Tablet (≤991.98px): sidebar already collapses via shell rules above ---------- */
@media (max-width: 991.98px) {
  .stat-tile-number { font-size: 1.3rem; }
  .row.g-3 > [class*="col-md-3"] { flex: 0 0 50%; max-width: 50%; } /* 2-up stat tiles on tablet */
  .nav-tabs { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: thin; }
  .nav-tabs .nav-link { white-space: nowrap; }
  .topbar-title h1 { max-width: 45vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* ---------- Small tablet / large phone (≤767.98px) ---------- */
@media (max-width: 767.98px) {
  .row.g-3 > [class*="col-md-3"] { flex: 0 0 100%; max-width: 100%; } /* stack stat tiles */
  .card { border-radius: var(--radius-md); }
  .stat-tile { padding: 1rem; }
  h1, .brand-font, h4, h5 { line-height: 1.25; }
  .table-responsive { border-radius: var(--radius-sm); }
  .workflow-stepper { gap: .3rem; }
  .workflow-stepper .step { font-size: .66rem; padding: .45rem .25rem; }
  .workflow-stepper .connector { width: 6px; }
  .btn { padding: .42rem .9rem; }
}

/* ---------- Phone (≤575.98px) ---------- */
@media (max-width: 575.98px) {
  .topbar-title h1 { max-width: 38vw; font-size: .95rem; }
  .topbar-actions { gap: .35rem; }
  .topbar-user-btn span { display: none !important; }
  .content-area { padding: .85rem; }
  .card.p-3 { padding: .9rem !important; }
  .stat-tile { flex-direction: column; align-items: flex-start; gap: .5rem; }
  .stat-tile-icon { width: 40px; height: 40px; font-size: 1.05rem; }
  .login-card .card-body { padding: 2rem 1.4rem; }
  .table td, .table th { padding: .5rem .6rem; font-size: .8rem; }
  .btn-sm { padding: .28rem .65rem; font-size: .76rem; }
  .d-flex.justify-content-between.flex-wrap { row-gap: .6rem; }
}

/* ---------- Very small (≤400px) ---------- */
@media (max-width: 400px) {
  .sidebar { width: 82vw; max-width: 280px; }
  .stat-tile-number { font-size: 1.15rem; }
  .topbar { padding: .6rem .75rem; }
}

/* ---------- Print ---------- */
@media print {
  .sidebar, .topbar, .app-footer, .no-print { display: none !important; }
  .main-wrap { width: 100%; }
  .content-area { padding: 0; }
}

/* ---------- Utility: ensure tables scroll smoothly without layout jump ---------- */
.table-responsive { -webkit-overflow-scrolling: touch; scrollbar-width: thin; scrollbar-color: #C8D6D3 transparent; }
.table-responsive::-webkit-scrollbar { height: 8px; }
.table-responsive::-webkit-scrollbar-thumb { background: #C8D6D3; border-radius: 999px; }

/* ---------- Utility: form grids already use Bootstrap col-md-*, this tightens gaps on mobile ---------- */
@media (max-width: 575.98px) {
  .row.g-3, .row.g-2 { row-gap: .6rem; }
}

/* ---------- Chunked uploader ---------- */
.chunk-progress-row { margin-bottom: .6rem; }
.chunk-progress-name { color: var(--ink); }
.chunk-drop-zone {
  border: 2px dashed #D7E2E0; border-radius: var(--radius-md);
  padding: 1.5rem; text-align: center; color: var(--gray);
  transition: border-color .15s ease, background .15s ease;
  cursor: pointer;
}
.chunk-drop-zone:hover, .chunk-drop-zone.dragover { border-color: var(--brand-teal); background: var(--brand-teal-light); }
.chunk-drop-zone i { font-size: 1.8rem; color: var(--brand-teal); }

/* ---------- Drive ---------- */
.drive-folder-card {
  display: flex; align-items: center; gap: .75rem;
  padding: 1rem; border-radius: var(--radius-md); background: var(--card-bg); box-shadow: var(--shadow-sm);
  text-decoration: none; color: var(--ink); transition: box-shadow .2s ease, transform .2s ease;
}
.drive-folder-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); color: var(--ink); }
.drive-folder-icon { width: 44px; height: 44px; border-radius: 12px; background: var(--brand-teal-light); color: var(--brand-teal); display: flex; align-items: center; justify-content: center; font-size: 1.3rem; flex-shrink: 0; }
.drive-folder-name { font-weight: 600; font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.drive-folder-meta { font-size: .72rem; color: var(--gray); }

.drive-file-row { display: flex; align-items: center; gap: .75rem; padding: .6rem .3rem; border-bottom: 1px solid #F0F2F1; }
.drive-file-row:last-child { border-bottom: none; }
.drive-file-icon { width: 36px; height: 36px; border-radius: 9px; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 1rem; flex-shrink: 0; }
.drive-file-name { font-size: .85rem; font-weight: 600; color: var(--ink); }
.drive-file-meta { font-size: .72rem; color: var(--gray); }

/* =====================================================================
   MODAL ROBUSTNESS — guarantee modals always sit above everything else
   and are never accidentally blocked from receiving clicks.
   ===================================================================== */
.modal { z-index: 1060 !important; }
.modal-backdrop { z-index: 1050 !important; }
.modal, .modal * { pointer-events: auto; }
/* Belt-and-suspenders: if a backdrop is ever left in the DOM without a visible modal
   (e.g. an interrupted close), it must never be able to block the page underneath. */
.modal-backdrop:not(.show) { display: none !important; }

/* General-purpose border color variable, used by .transmit-panel and a few other components. */
:root { --border-color: #E2E8E6; }

/* =====================================================================
   SMOOTHER MOTION
   Refines the existing entrance animations with a touch more polish, plus
   a consistent, snappy transition on interactive elements. No new classes
   required on any page — these apply to the same selectors already in use.
   ===================================================================== */
* { scroll-behavior: smooth; }

.card, .stat-tile, .btn, .sidebar-link, .table tbody tr, input, select, textarea {
  transition: box-shadow .2s ease, transform .15s ease, background-color .25s ease, border-color .25s ease, color .2s ease;
}
.table tbody tr:hover { background-color: var(--brand-teal-light); }
.btn:active { transform: scale(.97); }
.card { animation: fadeInUp .4s cubic-bezier(.16,1,.3,1) both; }
.nav-tabs .nav-link { transition: all .2s ease; }
.badge { transition: transform .15s ease; }

/* Top loading bar — see includes/footer.php for the JS that drives it. */
#topLoadingBar {
  position: fixed; top: 0; left: 0; height: 3px; width: 0%; z-index: 2000;
  background: linear-gradient(90deg, var(--brand-gold), var(--brand-teal));
  box-shadow: 0 0 8px rgba(201,146,46,0.6);
  opacity: 0; pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}

/* Role & Access Matrix: highlights the matching row when a user is picked in the
   "Select a User's Role" tool above, so their allotted rights are easy to spot. */
.role-row-highlight {
  background-color: rgba(201,146,46,0.16) !important;
  box-shadow: inset 3px 0 0 var(--brand-gold);
  transition: background-color .3s ease;
}

/* About page feature grid icon badges */
.feature-icon-badge {
  width: 44px; height: 44px; border-radius: 12px;
  background: var(--brand-teal-light); color: var(--brand-teal);
  display: flex; align-items: center; justify-content: center; font-size: 1.15rem;
}

/* Lab Data tab — Argus-style add panel + results grid */
.lab-add-panel-header {
  background: var(--brand-teal-dark, var(--brand-teal));
  color: #fff;
  font-weight: 600;
  font-size: .85rem;
  padding: .65rem 1rem;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  display: flex; align-items: center; gap: .4rem;
}
.lab-results-table thead th {
  background: var(--brand-teal-light);
  color: var(--brand-teal-dark, var(--brand-teal));
  font-size: .74rem; text-transform: uppercase; letter-spacing: .03em;
  border-bottom: 2px solid var(--brand-teal);
  white-space: nowrap;
}
.lab-results-table tbody tr:hover { background: var(--brand-teal-light); }

/* Lab Data tab v2 — test grouped with one column per date reading, matching a lab flow sheet */
.lab-test-group-header {
  background: var(--brand-teal-dark, var(--brand-teal));
  color: #fff;
  font-weight: 600;
  font-size: .85rem;
  padding: .6rem 1rem;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.lab-date-columns th {
  background: var(--brand-teal-light);
  color: var(--brand-teal-dark, var(--brand-teal));
  font-size: .72rem; text-transform: uppercase; letter-spacing: .03em;
  white-space: nowrap; width: 150px; vertical-align: middle;
}
.lab-date-columns td { min-width: 140px; vertical-align: middle; }
.lab-row-label:last-child td, .lab-row-label:last-child th { border-bottom: none; }

/* Lab Data tab v3 — field rows matching the reference layout (Test Name / Units / Norm
   Low-High / Date labels, with Add Test and Select Lab Test Group buttons in place) */
.lab-header-btn { font-size: .72rem; padding: .2rem .6rem; }
.lab-field-row { padding: .3rem 0; border-bottom: 1px dashed var(--border-color); }
.lab-field-label { font-size: .8rem; font-weight: 600; color: var(--brand-teal-dark, var(--brand-teal)); margin-bottom: 0; }
.lab-group-btn { font-size: .68rem; padding: .15rem .5rem; }
.lab-search-results {
  border: 1px solid var(--border-color); border-radius: var(--radius-sm, 6px);
  max-height: 160px; overflow-y: auto; background: #fff;
}
.lab-search-results:empty { border: none; }
.lab-search-result-row {
  padding: .4rem .6rem; font-size: .82rem; cursor: pointer;
  display: flex; justify-content: space-between; align-items: center;
  border-bottom: 1px solid var(--border-color);
}
.lab-search-result-row:last-child { border-bottom: none; }
.lab-search-result-row:hover { background: var(--brand-teal-light); }

/* =====================================================================
   Enterprise case-form styling — a compact toolbar strip + status/priority
   bar with a live countdown, and boxed tabs, in this app's own brand
   colors (not a literal copy of any specific third-party product's palette).
   ===================================================================== */
.case-form-card { overflow: hidden; }

.case-toolbar {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .5rem;
  background: var(--brand-teal-dark, var(--brand-teal));
  color: #fff;
  padding: .55rem 1rem;
}
.case-toolbar-title { font-weight: 700; font-size: 1.02rem; letter-spacing: .01em; }
.case-toolbar-actions { display: flex; align-items: center; gap: .35rem; }
.case-toolbar-btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 6px;
  background: rgba(255,255,255,0.1); color: #fff; border: none;
  transition: background .15s ease;
}
.case-toolbar-btn:hover { background: rgba(255,255,255,0.22); color: #fff; }
.case-toolbar-btn-danger:hover { background: var(--brand-coral); }
.case-toolbar-badge {
  position: absolute; top: -4px; right: -4px;
  background: var(--brand-gold); color: var(--brand-teal-dark);
  font-size: .6rem; font-weight: 700; line-height: 1;
  padding: .15em .35em; border-radius: 999px;
}

.case-status-bar {
  display: flex; flex-wrap: wrap; gap: 0;
  background: var(--brand-teal-light);
  border-bottom: 1px solid var(--border-color, #E2E8E6);
}
.case-status-item {
  padding: .5rem 1.1rem; border-right: 1px solid rgba(11,79,74,0.12);
  display: flex; flex-direction: column; gap: .1rem; min-width: 130px;
}
.case-status-item:last-child { border-right: none; }
.case-status-label { font-size: .65rem; text-transform: uppercase; letter-spacing: .04em; color: var(--brand-teal-dark, var(--brand-teal)); opacity: .75; }
.case-status-value { font-size: .88rem; font-weight: 600; color: var(--ink); display: flex; align-items: center; gap: .35rem; }
.case-status-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.case-countdown-item { margin-left: auto; }
.case-countdown { font-variant-numeric: tabular-nums; }

/* Boxed enterprise-style tabs for the case section navigation below the status bar. */
#viewTabs.nav-tabs { border-bottom: 2px solid var(--brand-teal); gap: 2px; flex-wrap: wrap; }
#viewTabs.nav-tabs .nav-link {
  border: 1px solid var(--border-color, #E2E8E6); border-bottom: none;
  border-radius: 4px 4px 0 0;
  background: var(--brand-teal-light);
  color: var(--brand-teal-dark, var(--brand-teal));
  font-size: .8rem; font-weight: 600; padding: .5rem .85rem;
}
#viewTabs.nav-tabs .nav-link:hover { background: #fff; }
#viewTabs.nav-tabs .nav-link.active {
  background: var(--brand-teal); color: #fff; border-color: var(--brand-teal);
}
