/* ==========================================================================
   ICU Staff Assignment Pro — Elite Clinical Blue & White Design System
   Visual Identity:
   - Primary Medical Blue:    #1D4ED8
   - Deep Hospital Navy:      #1E3A8A
   - Vibrant Medical Blue:    #2563EB
   - Soft Ice Blue Surface:   #EFF6FF
   - Subtle Accent Blue:      #DBEAFE
   - Pure White Surface:      #FFFFFF
   - App Clinical Background: #F8FAFC
   - Ink Primary Text:        #0F172A
   - Medium Slate Text:       #334155
   - Muted Slate Text:        #64748B
   - Crisp Slate Border:      #E2E8F0
   - Active Blue Border:      #93C5FD
   ========================================================================== */

:root {
  /* Hospital Blue & White Clinical Tokens */
  --blue-navy: #1E3A8A;
  --blue-primary: #1D4ED8;
  --blue-primary-hover: #1E40AF;
  --blue-vibrant: #2563EB;
  --blue-accent: #3B82F6;
  --blue-light: #93C5FD;
  --blue-subtle: #DBEAFE;
  --blue-surface: #EFF6FF;

  --bg-app: #F8FAFC;
  --surface-card: #FFFFFF;
  --surface-muted: #F1F5F9;

  --text-primary: #0F172A;
  --text-secondary: #334155;
  --text-muted: #64748B;
  --border-default: #E2E8F0;
  --border-strong: #CBD5E1;
  --border-blue: #BFDBFE;

  /* Semantic Clinical Tokens */
  --color-success: #0284C7;
  --color-success-bg: #E0F2FE;
  --color-warning: #D97706;
  --color-warning-bg: #FEF3C7;
  --color-danger: #DC2626;
  --color-danger-bg: #FEF2F2;
  --color-neutral: #64748B;

  /* Typography & Geometry */
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Segoe UI Arabic", "Cairo", Arial, sans-serif;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;

  /* Elevation */
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 8px -2px rgba(30, 58, 138, 0.08), 0 2px 4px -2px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 10px 20px -3px rgba(30, 58, 138, 0.1), 0 4px 6px -4px rgba(15, 23, 42, 0.05);
  --shadow-modal: 0 20px 25px -5px rgba(30, 58, 138, 0.15), 0 8px 10px -6px rgba(15, 23, 42, 0.1);
}

/* Global Reset */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  font-size: 14px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background-color: var(--bg-app);
  color: var(--text-primary);
  font-family: var(--font-family);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Inline SVG Icon Helper */
.icon {
  display: inline-block;
  width: 16px;
  height: 16px;
  vertical-align: middle;
  fill: currentColor;
  flex-shrink: 0;
}

.icon-lg {
  width: 20px;
  height: 20px;
}

.icon-xl {
  width: 28px;
  height: 28px;
}

/* ==========================================================================
   Header & Clinical Brand Bar
   ========================================================================== */
header {
  background: linear-gradient(135deg, var(--blue-navy) 0%, #1e40af 100%);
  color: #ffffff;
  padding: 14px 24px;
  position: sticky;
  top: 0;
  z-index: 40;
  border-bottom: 3px solid var(--blue-vibrant);
  box-shadow: var(--shadow-md);
}

.header-container {
  max-width: 1400px;
  margin: auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon-box {
  width: 40px;
  height: 40px;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  flex-shrink: 0;
  backdrop-filter: blur(4px);
}

.brand-text h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #ffffff;
}

.brand-text small {
  display: block;
  font-size: 0.82rem;
  color: #dbeafe;
  opacity: 0.95;
  margin-top: 1px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sync-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  user-select: none;
  backdrop-filter: blur(4px);
}

.sync-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.sync-dot.online {
  background: #38bdf8;
  box-shadow: 0 0 8px #38bdf8;
}

.sync-dot.syncing {
  background: #fbbf24;
  box-shadow: 0 0 8px #fbbf24;
  animation: pulse-dot 1s infinite;
}

.sync-dot.offline {
  background: #94a3b8;
}

.sync-dot.error {
  background: var(--color-danger);
  box-shadow: 0 0 8px var(--color-danger);
}

@keyframes pulse-dot {
  0%, 100% { opacity: 0.4; transform: scale(0.9); }
  50% { opacity: 1; transform: scale(1.15); }
}

/* ==========================================================================
   Main Content Layout
   ========================================================================== */
main {
  max-width: 1400px;
  width: 100%;
  margin: auto;
  padding: 20px 20px 48px;
  flex: 1;
}

/* ==========================================================================
   Navigation Tabs
   ========================================================================== */
.tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
  margin-bottom: 20px;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

.tab {
  background: var(--surface-card);
  color: var(--text-secondary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 10px 20px;
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.15s ease-in-out;
  min-height: 42px;
}

.tab:hover {
  background: var(--blue-surface);
  color: var(--blue-primary);
  border-color: var(--blue-subtle);
}

.tab.active {
  background: var(--blue-primary);
  color: #ffffff;
  border-color: var(--blue-primary);
  box-shadow: var(--shadow-sm);
}

.tab.active .icon {
  fill: #ffffff;
}

/* ==========================================================================
   Cards & Surfaces
   ========================================================================== */
.card {
  background: var(--surface-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: 22px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s ease;
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-default);
}

.card h2 {
  margin: 0;
  font-size: 1.18rem;
  font-weight: 700;
  color: var(--blue-navy);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card h2 .icon {
  fill: var(--blue-primary);
}

/* ==========================================================================
   Form Controls, Inputs & Typography
   ========================================================================== */
label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

label .icon {
  width: 14px;
  height: 14px;
  fill: var(--text-muted);
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  background-color: #ffffff;
  color: var(--text-primary);
  font-size: 0.92rem;
  font-family: inherit;
  transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

input:hover,
select:hover {
  border-color: var(--border-strong);
}

input:focus,
select:focus {
  outline: 0;
  border-color: var(--blue-vibrant);
  background-color: #ffffff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.16);
}

input:disabled,
select:disabled {
  background-color: var(--surface-muted);
  color: var(--text-muted);
  cursor: not-allowed;
  border-color: var(--border-default);
}

/* Button System */
button {
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: 9px 18px;
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: all 0.15s ease-in-out;
  font-family: inherit;
  user-select: none;
}

button:active {
  transform: translateY(1px);
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.primary {
  background-color: var(--blue-primary);
  color: #ffffff;
  border-color: var(--blue-primary);
  box-shadow: var(--shadow-sm);
}

.primary:hover:not(:disabled) {
  background-color: var(--blue-primary-hover);
  border-color: var(--blue-primary-hover);
}

.secondary {
  background-color: #ffffff;
  color: var(--text-primary);
  border-color: var(--border-default);
}

.secondary:hover:not(:disabled) {
  background-color: var(--blue-surface);
  color: var(--blue-navy);
  border-color: var(--blue-subtle);
}

.ok {
  background-color: var(--blue-navy);
  color: #ffffff;
  border-color: var(--blue-navy);
  box-shadow: var(--shadow-sm);
}

.ok:hover:not(:disabled) {
  background-color: #172554;
  border-color: #172554;
}

.danger {
  background-color: #ffffff;
  color: var(--color-danger);
  border-color: #fca5a5;
}

.danger:hover:not(:disabled) {
  background-color: var(--color-danger-bg);
  border-color: var(--color-danger);
}

.warn {
  background-color: var(--color-warning-bg);
  color: var(--color-warning);
  border-color: #fde68a;
}

/* Toolbar & Action Row */
.toolbar-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 14px 0 4px;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.grid2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

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

/* Clinical Callouts & Notices */
.notice {
  background-color: var(--blue-surface);
  color: var(--blue-navy);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  border-left: 4px solid var(--blue-primary);
  line-height: 1.5;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.notice .icon {
  fill: var(--blue-primary);
  margin-top: 2px;
}

/* ==========================================================================
   Shift Statistics Counters
   ========================================================================== */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.stat {
  border: 1px solid var(--border-default);
  border-top: 3px solid var(--blue-primary);
  border-radius: var(--radius-md);
  padding: 16px;
  background: #ffffff;
  text-align: center;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.stat:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat span {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.stat span .icon {
  fill: var(--blue-primary);
}

.stat b {
  display: block;
  font-size: 1.85rem;
  font-weight: 800;
  color: var(--blue-navy);
  margin-top: 6px;
  line-height: 1.1;
}

/* ==========================================================================
   Staff Selection Chips
   ========================================================================== */
.staff-pick {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.staff-pick label {
  margin: 0;
  cursor: pointer;
}

.staff-pick input {
  display: none;
}

.staff-pick span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-full);
  padding: 7px 14px;
  background: #ffffff;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-primary);
  user-select: none;
  transition: all 0.15s ease;
}

.staff-pick span:hover {
  background: var(--blue-surface);
  border-color: var(--blue-subtle);
  color: var(--blue-primary);
}

.staff-pick input:checked + span {
  background: var(--blue-surface);
  border-color: var(--blue-primary);
  color: var(--blue-primary);
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(37, 99, 235, 0.15);
}

/* ==========================================================================
   12 ICU Bed Assignment Cards
   ========================================================================== */
.assignment {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.bedrow {
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: 16px;
  background: #ffffff;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.bedrow:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}

.bedrow.dragover {
  outline: 2px dashed var(--blue-primary);
  outline-offset: -2px;
  background: var(--blue-surface);
}

.bedhead {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-default);
  gap: 10px;
}

.bed-badge-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.bednum {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--blue-navy);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.bednum .icon {
  fill: var(--blue-primary);
}

.zone-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: var(--blue-surface);
  color: var(--blue-primary);
  border: 1px solid var(--blue-subtle);
}

.nurse {
  font-weight: 700;
  color: var(--blue-navy);
  font-size: 0.88rem;
  background: var(--blue-surface);
  padding: 4px 10px;
  border-radius: var(--radius-md);
  border: 1px solid var(--blue-subtle);
  max-width: 55%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Patient Card Container */
.patient {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: #f8fafc;
  border: 1px solid var(--border-default);
  cursor: grab;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.patient:active {
  cursor: grabbing;
  background: #ffffff;
  border-color: var(--blue-primary);
}

.patient-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.patient-name {
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--text-primary);
}

.pin {
  background: var(--color-warning-bg);
  color: var(--color-warning);
  border: 1px solid #fde68a;
  padding: 3px 8px;
  min-height: unset;
  font-size: 0.78rem;
  font-weight: 700;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.pin .icon {
  width: 12px;
  height: 12px;
  fill: var(--color-warning);
}

.patient-clinical-info {
  font-size: 0.86rem;
  color: var(--text-secondary);
  line-height: 1.55;
}

.patient-tags-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: var(--radius-full);
  padding: 3px 9px;
  background: var(--bg-app);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  border: 1px solid var(--border-default);
}

.tag .icon {
  width: 12px;
  height: 12px;
  fill: currentColor;
}

.tag.device-active {
  background: var(--blue-surface);
  color: var(--blue-primary);
  border-color: var(--blue-subtle);
  font-weight: 700;
}

.tag.isolation-alert {
  background: var(--color-danger-bg);
  color: var(--color-danger);
  border-color: #fca5a5;
  font-weight: 700;
}

.empty {
  color: var(--text-muted);
  padding: 24px 14px;
  text-align: center;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  font-weight: 500;
  background: #f8fafc;
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.empty .icon {
  fill: var(--text-muted);
}

/* ==========================================================================
   Additional Tasks
   ========================================================================== */
.taskgrid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.task {
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 14px;
  background: #ffffff;
}

.task b {
  display: block;
  margin-bottom: 8px;
  font-size: 0.92rem;
  color: var(--blue-navy);
}

/* ==========================================================================
   Clinical Data Tables
   ========================================================================== */
.tablewrap {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-default);
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  background: #ffffff;
  min-width: 800px;
}

th,
td {
  border-bottom: 1px solid var(--border-default);
  padding: 11px 14px;
  text-align: left;
  vertical-align: middle;
}

th {
  background: var(--blue-surface);
  font-weight: 700;
  color: var(--blue-navy);
  font-size: 0.82rem;
  letter-spacing: 0.02em;
  border-bottom: 2px solid var(--blue-subtle);
}

tr:hover td {
  background: #f8fafc;
}

/* ==========================================================================
   Login Screen & Modals
   ========================================================================== */
.login {
  max-width: 440px;
  width: 92%;
  margin: 10vh auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-default);
  box-shadow: var(--shadow-modal);
  padding: 32px;
  background: #ffffff;
}

.login h2 {
  margin-top: 12px;
  color: var(--blue-navy);
  font-size: 1.35rem;
  text-align: center;
}

.login-icon-wrap {
  text-align: center;
  color: var(--blue-primary);
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 20px;
  right: 20px;
  max-width: 480px;
  margin: auto;
  background: var(--blue-navy);
  color: #ffffff;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  display: none;
  z-index: 60;
  box-shadow: var(--shadow-lg);
  font-size: 0.9rem;
  text-align: center;
  font-weight: 500;
  border: 1px solid var(--blue-primary);
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: none;
  place-items: center;
  z-index: 50;
  padding: 16px;
  backdrop-filter: blur(3px);
}

.modal-content {
  background: var(--surface-card);
  border-radius: var(--radius-lg);
  padding: 24px;
  max-width: 480px;
  width: 100%;
  box-shadow: var(--shadow-modal);
  border: 1px solid var(--border-default);
}

.modal-content h3 {
  margin: 0 0 12px 0;
  color: var(--blue-navy);
  font-size: 1.15rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-content h3 .icon {
  fill: var(--color-danger);
}

/* ==========================================================================
   Utilities & State Helpers
   ========================================================================== */
.hidden {
  display: none !important;
}

.mini {
  font-size: 0.76rem;
  font-weight: normal;
  display: block;
}

/* ==========================================================================
   Responsive Adaptations
   ========================================================================== */
@media (min-width: 1200px) {
  .assignment {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 991px) {
  .stats {
    grid-template-columns: repeat(2, 1fr);
  }
  .taskgrid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 767px) {
  main {
    padding: 14px 12px 32px;
  }
  .assignment {
    grid-template-columns: 1fr;
  }
  .grid2 {
    grid-template-columns: 1fr;
  }
  .stats {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  .stat {
    padding: 10px;
  }
  .stat b {
    font-size: 1.45rem;
  }
  .card {
    padding: 16px;
    border-radius: var(--radius-md);
  }
  .toolbar-row {
    flex-direction: column;
    align-items: stretch;
  }
  .toolbar-group {
    width: 100%;
    flex-direction: column;
  }
  .toolbar-group button,
  .toolbar-row > button {
    width: 100%;
  }
  button {
    min-height: 44px;
  }
  header {
    padding: 12px 16px;
  }
  .brand-text h1 {
    font-size: 1.1rem;
  }
  .brand-text small {
    font-size: 0.75rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
