/* neotrack.css — NeoTrack clinical workspace layout. Extends shell.css. */
/* Strict Material Design 3 (Android). No CSS framework. */

/* ═══════════════════════════════════════════════════════════════════════════
   TWO-PANEL LAYOUT
   ══════════════════════════════════════════════════════════════════════════ */

.neotrack-layout {
  position: fixed;
  top: var(--topbar-h);
  left: 0;
  right: 0;
  bottom: var(--navbar-h);   /* account for mobile nav bar */
  display: flex;
  overflow: hidden;
  background: var(--md-surface);
}

/* Desktop: nav rail shifts content right, no bottom nav bar */
@media (min-width: 840px) {
  .neotrack-layout {
    left: 80px;
    bottom: 0;
  }
}
@media (min-width: 1280px) {
  .neotrack-layout { left: 88px; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   ROSTER PANEL
   ══════════════════════════════════════════════════════════════════════════ */

.roster-panel {
  width: 100%;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--md-surface-container-low);
  border-right: 1px solid var(--md-outline-variant);
  overflow: hidden;
}

@media (min-width: 840px) {
  .roster-panel { width: 340px; }
}

/* Mobile: hide roster when detail is active */
@media (max-width: 839px) {
  .mobile-detail-active .roster-panel { display: none; }
}

.roster-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--md-outline-variant);
  background: var(--md-surface-container);
  flex-shrink: 0;
}

.hospital-select-wrap {
  flex: 1;
  position: relative;
}

.hospital-select-wrap select {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--md-on-surface);
  font-size: 16px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  appearance: none;
  padding-right: 24px;
}

.hospital-select-wrap::after {
  content: '▾';
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  color: var(--md-on-surface-variant);
  font-size: 12px;
  pointer-events: none;
}

/* Filter chips row */
.filter-row-nt {
  display: flex;
  gap: 8px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--md-outline-variant);
  flex-shrink: 0;
}

/* Patient list — scrollable */
.patient-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}

/* MD3 List Item — Two-line, leading avatar, trailing meta */
.patient-list-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  cursor: pointer;
  min-height: 72px;
  transition: background 180ms ease;
  position: relative;
}

.patient-list-item::after {
  content: '';
  position: absolute;
  inset: 0;
  background: transparent;
  transition: background 180ms ease;
  pointer-events: none;
}

.patient-list-item:hover::after  { background: rgba(78,205,196,0.08); }
.patient-list-item:active::after { background: rgba(78,205,196,0.12); }

.patient-list-item.selected {
  background: var(--md-primary-container);
}
.patient-list-item.selected .patient-name { color: var(--md-on-primary-container); }
.patient-list-item.selected .patient-sub  { color: var(--md-on-primary-container); opacity: 0.75; }

/* Patient avatar — MD3 standard avatar */
.patient-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--md-secondary-container);
  color: var(--md-on-secondary-container);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.5px;
  flex-shrink: 0;
  user-select: none;
}

.patient-info { flex: 1; min-width: 0; }

.patient-name {
  font-size: 16px;
  font-weight: 500;
  color: var(--md-on-surface);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
}

.patient-sub {
  font-size: 14px;
  color: var(--md-on-surface-variant);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
  margin-top: 1px;
}

.patient-trailing {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}

.patient-days {
  font-size: 12px;
  color: var(--md-on-surface-variant);
  font-weight: 500;
}

.patient-list-empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--md-on-surface-variant);
  font-size: 14px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   DETAIL PANEL
   ══════════════════════════════════════════════════════════════════════════ */

.detail-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--md-surface);
}

/* Mobile: detail panel hidden unless active */
@media (max-width: 839px) {
  .detail-panel { display: none; }
  .mobile-detail-active .detail-panel {
    display: flex;
    width: 100%;
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
  }
}

/* Empty state */
.detail-empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--md-on-surface-variant);
  font-size: 16px;
  gap: 12px;
}

.detail-empty-icon {
  font-size: 48px;
  opacity: 0.5;
}

/* Patient header card — elevated surface */
.patient-header-card {
  background: var(--md-surface-container);
  border-bottom: 1px solid var(--md-outline-variant);
  padding: 16px 20px;
  flex-shrink: 0;
}

.patient-header-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  justify-content: space-between;
}

.patient-header-name {
  font-size: 22px;
  font-weight: 500;
  color: var(--md-on-surface);
  line-height: 1.3;
}

.patient-header-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin-top: 4px;
}

.patient-header-meta-item {
  font-size: 13px;
  color: var(--md-on-surface-variant);
}

.patient-header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════════════════════════
   MD3 PRIMARY TABS (patient detail sections)
   ══════════════════════════════════════════════════════════════════════════ */

.tab-bar-primary {
  display: flex;
  border-bottom: 1px solid var(--md-outline-variant);
  background: var(--md-surface-container);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  flex-shrink: 0;
}

.tab-bar-primary::-webkit-scrollbar { display: none; }

.tab-btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 24px;
  height: 48px;
  min-width: max-content;
  font-size: 14px;
  font-weight: 500;
  color: var(--md-on-surface-variant);
  background: transparent;
  border: none;
  cursor: pointer;
  position: relative;
  white-space: nowrap;
  letter-spacing: 0.1px;
  transition: color 180ms ease;
}

.tab-btn-primary:hover { color: var(--md-on-surface); background: rgba(78,205,196,0.08); }

.tab-btn-primary.active {
  color: var(--md-primary);
}

.tab-btn-primary.active::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 3px;
  background: var(--md-primary);
  border-radius: 3px 3px 0 0;
}

/* Tab content scroll area */
.tab-content-area {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   OVERVIEW TAB
   ══════════════════════════════════════════════════════════════════════════ */

.overview-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--md-surface-container);
  border-radius: var(--md-shape-md);
  padding: 14px 16px;
  text-align: center;
}

.stat-card-value {
  font-size: 28px;
  font-weight: 600;
  color: var(--md-primary);
  line-height: 1.1;
}

.stat-card-label {
  font-size: 12px;
  color: var(--md-on-surface-variant);
  margin-top: 4px;
}

.editable-field {
  margin-bottom: 16px;
}

.editable-field-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--md-on-surface-variant);
  margin-bottom: 4px;
}

.editable-field-value {
  font-size: 15px;
  color: var(--md-on-surface);
  padding: 4px 0;
  border-bottom: 1px solid transparent;
  cursor: pointer;
  transition: border-color 180ms;
}

.editable-field-value:hover { border-color: var(--md-outline); }

/* ═══════════════════════════════════════════════════════════════════════════
   LABS TAB — Data table
   ══════════════════════════════════════════════════════════════════════════ */

.lab-group {
  margin-bottom: 20px;
}

.lab-group-date {
  font-size: 13px;
  font-weight: 600;
  color: var(--md-on-surface-variant);
  padding: 6px 0;
  border-bottom: 1px solid var(--md-outline-variant);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--md-surface-container-lowest);
  border-radius: var(--md-shape-sm);
  overflow: hidden;
}

.data-table th {
  background: var(--md-surface-container);
  color: var(--md-on-surface-variant);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 10px 12px;
  text-align: left;
}

.data-table td {
  padding: 9px 12px;
  font-size: 13px;
  color: var(--md-on-surface);
  border-top: 1px solid var(--md-outline-variant);
}

.data-table tr:hover td { background: rgba(78,205,196,0.04); }

.flag-high     { color: #FF6B6B; font-weight: 700; }
.flag-low      { color: #74B9FF; font-weight: 700; }
.flag-critical { color: #FF6B6B; background: rgba(255,107,107,0.12); font-weight: 700; padding: 2px 6px; border-radius: 4px; }
.flag-none     { color: var(--md-on-surface-variant); }

.verified-check { color: #69E587; font-size: 14px; }

/* Lab entry form — inline table */
.lab-entry-table { width: 100%; border-collapse: collapse; }
.lab-entry-table th {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.4px; color: var(--md-on-surface-variant);
  padding: 6px 8px; text-align: left; border-bottom: 1px solid var(--md-outline-variant);
}
.lab-entry-table td { padding: 4px 4px; vertical-align: middle; }

.lab-entry-input {
  width: 100%;
  background: var(--md-surface-container);
  border: 1px solid var(--md-outline);
  border-radius: var(--md-shape-xs);
  color: var(--md-on-surface);
  font-size: 13px;
  font-family: inherit;
  padding: 6px 8px;
  outline: none;
  transition: border-color 180ms;
}
.lab-entry-input:focus { border-color: var(--md-primary); }

.flag-select {
  background: var(--md-surface-container);
  border: 1px solid var(--md-outline);
  border-radius: var(--md-shape-xs);
  color: var(--md-on-surface);
  font-size: 12px;
  font-family: inherit;
  padding: 6px 4px;
  outline: none;
  width: 90px;
}

.analyte-preset-select {
  background: var(--md-surface-container);
  border: 1px solid var(--md-outline);
  border-radius: var(--md-shape-xs);
  color: var(--md-on-surface);
  font-size: 13px;
  font-family: inherit;
  padding: 8px 12px;
  outline: none;
  cursor: pointer;
}

/* ═══════════════════════════════════════════════════════════════════════════
   MEDICATIONS / ORDERS / BILLING — Reusable list
   ══════════════════════════════════════════════════════════════════════════ */

.clinical-list { display: flex; flex-direction: column; gap: 8px; }

.clinical-list-item {
  background: var(--md-surface-container);
  border-radius: var(--md-shape-sm);
  padding: 12px 14px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.clinical-list-item.stopped { opacity: 0.5; }
.clinical-list-item.completed { opacity: 0.6; }

.clinical-list-content { flex: 1; min-width: 0; }
.clinical-list-headline { font-size: 14px; font-weight: 500; color: var(--md-on-surface); }
.clinical-list-sub { font-size: 12px; color: var(--md-on-surface-variant); margin-top: 2px; }
.clinical-list-actions { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }

/* Section header with action button */
.tab-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.tab-section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--md-on-surface-variant);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Billing total */
.billing-total {
  background: var(--md-primary-container);
  border-radius: var(--md-shape-md);
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 16px;
}

.billing-total-label { font-size: 14px; font-weight: 500; color: var(--md-on-primary-container); }
.billing-total-value { font-size: 20px; font-weight: 600; color: var(--md-on-primary-container); }

/* ═══════════════════════════════════════════════════════════════════════════
   DIALOGS (MD3 Basic Dialog)
   ══════════════════════════════════════════════════════════════════════════ */

.dialog-scrim {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
}

.dialog {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--md-surface-container-high);
  border-radius: var(--md-shape-xl);
  padding: 24px;
  width: min(480px, calc(100vw - 48px));
  max-height: calc(100vh - 80px);
  overflow-y: auto;
  z-index: 201;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

.dialog-headline {
  font-size: 20px;
  font-weight: 500;
  color: var(--md-on-surface);
  margin-bottom: 16px;
  line-height: 1.3;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 24px;
}

/* MD3 Outlined text field (for forms) */
.field {
  position: relative;
  margin-bottom: 14px;
}

.field label {
  display: block;
  font-size: 12px;
  color: var(--md-on-surface-variant);
  font-weight: 500;
  margin-bottom: 4px;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  background: var(--md-surface-container-highest);
  border: 1px solid var(--md-outline);
  border-radius: var(--md-shape-xs);
  color: var(--md-on-surface);
  font-size: 14px;
  font-family: inherit;
  padding: 10px 14px;
  outline: none;
  transition: border-color 180ms;
}

.field input:focus,
.field select:focus,
.field textarea:focus { border-color: var(--md-primary); box-shadow: 0 0 0 2px rgba(78,205,196,0.2); }

.field textarea { resize: vertical; min-height: 72px; }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ═══════════════════════════════════════════════════════════════════════════
   DOCUMENT VIEWER MODAL
   ══════════════════════════════════════════════════════════════════════════ */

.doc-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.doc-modal {
  background: #FFF;
  border-radius: var(--md-shape-lg);
  width: min(900px, 100%);
  max-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 16px 64px rgba(0,0,0,0.5);
}

.doc-modal-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--md-surface-container);
  border-bottom: 1px solid var(--md-outline-variant);
  flex-shrink: 0;
}

.doc-modal-title { font-size: 14px; font-weight: 500; color: var(--md-on-surface); }

.doc-modal-iframe {
  flex: 1;
  border: none;
  background: #FFF;
}

/* ═══════════════════════════════════════════════════════════════════════════
   FLOATING EXTENDED FAB — End of Day Snapshot
   ══════════════════════════════════════════════════════════════════════════ */

.snapshot-fab {
  position: fixed;
  bottom: calc(var(--navbar-h) + 16px);
  right: 16px;
  background: var(--md-secondary-container);
  color: var(--md-on-secondary-container);
  border: none;
  border-radius: var(--md-shape-lg);
  height: 56px;
  padding: 0 20px 0 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 3px 8px rgba(0,0,0,0.3);
  z-index: 100;
  transition: box-shadow 180ms, transform 120ms;
  letter-spacing: 0.1px;
}

.snapshot-fab:hover { box-shadow: 0 6px 16px rgba(0,0,0,0.4); }
.snapshot-fab:active { transform: scale(0.97); }

@media (min-width: 840px) {
  .snapshot-fab {
    bottom: 24px;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   UTILITY BUTTONS (small — for rows)
   ══════════════════════════════════════════════════════════════════════════ */

.btn-icon-sm {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--md-on-surface-variant);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  transition: background 180ms;
  flex-shrink: 0;
}
.btn-icon-sm:hover { background: rgba(202,196,208,0.12); }
.btn-icon-sm.danger:hover { background: rgba(255,107,107,0.15); color: var(--md-error); }

/* Status chips for orders/billing */
.status-chip {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: var(--md-shape-full);
  white-space: nowrap;
}
.status-chip.pending   { background: var(--md-secondary-container); color: var(--md-on-secondary-container); }
.status-chip.completed { background: rgba(105,229,135,0.2); color: #69E587; }
.status-chip.paid      { background: rgba(105,229,135,0.2); color: #69E587; }
.status-chip.unpaid    { background: rgba(255,180,69,0.2);  color: var(--md-secondary); }

/* Small tonal FAB for roster "Add Patient" */
.roster-add-btn {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--md-primary-container);
  color: var(--md-on-primary-container);
  font-size: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: box-shadow 180ms;
}
.roster-add-btn:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.3); }

/* ═══════════════════════════════════════════════════════════════════════════
   LOADING SHIMMER (roster)
   ══════════════════════════════════════════════════════════════════════════ */

.shimmer {
  background: linear-gradient(90deg, var(--md-surface-container) 25%, var(--md-surface-container-high) 50%, var(--md-surface-container) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--md-shape-xs);
}

@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
