/* ═══════════════════════════════════════════════════════════════════════════════
   Tadawi Healthcare ERP — Visit Workspace
   Prefix: vw-
   ═══════════════════════════════════════════════════════════════════════════════ */

:root {
  --vw-card-bg: var(--card-bg, #fff);
  --vw-border: var(--border, #e2e8f0);
  --vw-text: var(--text, #1e293b);
  --vw-text-secondary: var(--text-secondary, #94a3b8);
  --vw-bg-secondary: var(--bg-secondary, #f1f5f9);
  --vw-primary: var(--primary, #28B8D6);
  --vw-primary-hover: #5558e6;
  --vw-success: #10b981;
  --vw-danger: #ef4444;
  --vw-warning: #f59e0b;
  --vw-info: #3b82f6;
  --vw-radius: 8px;
  --vw-radius-lg: 12px;
  --vw-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --vw-shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
  --vw-transition: 0.2s ease;
}

/* ─── Container ─────────────────────────────────────────────────────────────── */
.vw-container {
  width: 100%;
  min-height: 100vh;
  padding: 16px;
  box-sizing: border-box;
  font-family: var(--font);
  color: var(--vw-text);
  background: var(--vw-bg-secondary);
}

/* ─── Header ────────────────────────────────────────────────────────────────── */
.vw-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: var(--vw-card-bg);
  border: 1px solid var(--vw-border);
  border-radius: var(--vw-radius-lg);
  margin-bottom: 16px;
  box-shadow: var(--vw-shadow);
}

.vw-header__title {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0;
  color: var(--vw-text);
}

.vw-header__subtitle {
  margin: 4px 0 0;
  font-size: 0.875rem;
  color: var(--vw-text-secondary);
}

.vw-header__right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ─── Filters ───────────────────────────────────────────────────────────────── */
.vw-filters {
  background: var(--vw-card-bg);
  border: 1px solid var(--vw-border);
  border-radius: var(--vw-radius-lg);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--vw-shadow);
}

.vw-filters__row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.vw-filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 140px;
}

.vw-filter-group--search {
  flex: 1;
  min-width: 200px;
}

/* ─── Workspace Layout (3-panel) ────────────────────────────────────────────── */
.vw-workspace {
  display: grid;
  grid-template-columns: 1fr 2fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
  min-height: calc(100vh - 250px);
}

/* ─── Panels ────────────────────────────────────────────────────────────────── */
.vw-panel {
  background: var(--vw-card-bg);
  border: 1px solid var(--vw-border);
  border-radius: var(--vw-radius-lg);
  padding: 16px;
  box-shadow: var(--vw-shadow);
  overflow-y: auto;
  max-height: calc(100vh - 200px);
}

.vw-panel::-webkit-scrollbar {
  width: 6px;
}

.vw-panel::-webkit-scrollbar-track {
  background: transparent;
}

.vw-panel::-webkit-scrollbar-thumb {
  background: var(--vw-border);
  border-radius: 3px;
}

/* ─── Left Panel ────────────────────────────────────────────────────────────── */
.vw-left-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ─── Center Panel ──────────────────────────────────────────────────────────── */
.vw-center-panel {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
  overflow: hidden;
}

/* ─── Right Panel ───────────────────────────────────────────────────────────── */
.vw-right-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ─── Patient Card ──────────────────────────────────────────────────────────── */
.vw-patient-card {
  display: flex;
  gap: 12px;
  padding: 16px;
  background: var(--vw-bg-secondary);
  border-radius: var(--vw-radius);
  border: 1px solid var(--vw-border);
}

.vw-patient-card__avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--vw-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  flex-shrink: 0;
}

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

.vw-patient-card__name {
  font-size: 1rem;
  font-weight: 700;
  margin: 0 0 4px;
  color: var(--vw-text);
}

.vw-patient-card__meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.vw-patient-card__contact {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* ─── Alert Card ────────────────────────────────────────────────────────────── */
.vw-alert-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.vw-alert-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-left: 3px solid var(--vw-danger);
  border-radius: var(--vw-radius);
  font-size: 0.8125rem;
}

.vw-alert-card__icon {
  font-size: 1rem;
  flex-shrink: 0;
}

.vw-alert-card__info {
  flex: 1;
  min-width: 0;
}

.vw-alert-card__type {
  font-weight: 600;
  color: #991b1b;
}

.vw-alert-card__detail {
  color: #b91c1c;
  margin-top: 2px;
}

/* ─── Medications List ──────────────────────────────────────────────────────── */
.vw-medications-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.vw-med-item {
  padding: 8px 10px;
  background: var(--vw-bg-secondary);
  border-radius: var(--vw-radius);
  border: 1px solid var(--vw-border);
}

.vw-med-item__name {
  font-weight: 600;
  font-size: 0.8125rem;
  color: var(--vw-text);
}

.vw-med-item__detail {
  font-size: 0.75rem;
  color: var(--vw-text-secondary);
  margin-top: 2px;
}

/* ─── Previous Visits ───────────────────────────────────────────────────────── */
.vw-previous-visits {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.vw-prev-visit {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  background: var(--vw-bg-secondary);
  border-radius: var(--vw-radius);
  border: 1px solid var(--vw-border);
  cursor: pointer;
  transition: background var(--vw-transition), border-color var(--vw-transition);
}

.vw-prev-visit:hover {
  background: #e2e8f0;
  border-color: var(--vw-primary);
}

.vw-prev-visit__date {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--vw-text);
}

.vw-prev-visit__type {
  font-size: 0.75rem;
  color: var(--vw-text-secondary);
}

/* ─── Visit Header ──────────────────────────────────────────────────────────── */
.vw-visit-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--vw-card-bg);
  border-bottom: 1px solid var(--vw-border);
  gap: 16px;
  flex-wrap: wrap;
}

.vw-visit-header__title {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0 0 8px;
}

.vw-visit-header__meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.vw-visit-header__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ─── Tabs ──────────────────────────────────────────────────────────────────── */
.vw-tabs {
  display: flex;
  border-bottom: 2px solid var(--vw-border);
  background: var(--vw-card-bg);
  padding: 0 16px;
  gap: 0;
  overflow-x: auto;
}

.vw-tab {
  padding: 12px 16px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--vw-text-secondary);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color var(--vw-transition), border-color var(--vw-transition);
  white-space: nowrap;
}

.vw-tab:hover {
  color: var(--vw-primary);
}

.vw-tab--active {
  color: var(--vw-primary);
  border-bottom-color: var(--vw-primary);
  font-weight: 600;
}

.vw-tab-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: var(--vw-card-bg);
}

.vw-tab-pane {
  display: block;
}

/* ─── Forms ─────────────────────────────────────────────────────────────────── */
.vw-form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}

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

.vw-form-actions {
  display: flex;
  gap: 8px;
  padding-top: 8px;
}

.vw-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--vw-text);
}

.vw-input,
.vw-select,
.vw-textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--vw-border);
  border-radius: var(--vw-radius);
  font-size: 0.875rem;
  color: var(--vw-text);
  background: var(--vw-card-bg);
  transition: border-color var(--vw-transition), box-shadow var(--vw-transition);
  box-sizing: border-box;
}

.vw-input:focus,
.vw-select:focus,
.vw-textarea:focus {
  outline: none;
  border-color: var(--vw-primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.vw-textarea {
  resize: vertical;
  min-height: 60px;
  font-family: inherit;
}

.vw-range {
  width: 100%;
  accent-color: var(--vw-primary);
}

/* ─── SOAP Section ──────────────────────────────────────────────────────────── */
.vw-soap-section {
  margin-bottom: 12px;
}

/* ─── Vitals Grid ───────────────────────────────────────────────────────────── */
.vw-vitals-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.vw-vitals-card {
  padding: 12px;
  background: var(--vw-bg-secondary);
  border: 1px solid var(--vw-border);
  border-radius: var(--vw-radius);
  text-align: center;
}

.vw-vitals-mini {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.vw-pain-value {
  font-weight: 700;
  font-size: 1.125rem;
  color: var(--vw-primary);
  margin-left: 8px;
}

/* ─── Diagnosis List ────────────────────────────────────────────────────────── */
.vw-diagnosis-controls {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  align-items: flex-end;
}

.vw-diagnosis-controls .vw-search-box {
  flex: 1;
  position: relative;
}

.vw-diagnosis-suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
  z-index: 100;
  max-height: 260px;
  overflow: hidden;
  display: none;
}
.vw-diagnosis-suggestions.open {
  display: block;
}

.vw-diagnosis-suggestion {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 0.8125rem;
  border-bottom: 1px solid var(--vw-border);
}

.vw-diagnosis-suggestion:last-child {
  border-bottom: none;
}

.vw-diagnosis-suggestion:hover {
  background: var(--vw-bg-secondary);
}

.vw-diagnosis-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.vw-diagnosis-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: var(--vw-bg-secondary);
  border: 1px solid var(--vw-border);
  border-radius: var(--vw-radius);
}

.vw-diagnosis-item__info {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.vw-diagnosis-item__code {
  font-weight: 700;
  font-family: 'SF Mono', SFMono-Regular, Consolas, monospace;
  font-size: 0.8125rem;
  color: var(--vw-primary);
}

.vw-diagnosis-item__name {
  font-size: 0.8125rem;
}

/* ─── Notes Editor ──────────────────────────────────────────────────────────── */
.vw-notes-toolbar {
  display: flex;
  gap: 4px;
  padding: 8px;
  border: 1px solid var(--vw-border);
  border-bottom: none;
  border-radius: var(--vw-radius) var(--vw-radius) 0 0;
  background: var(--vw-bg-secondary);
}

.vw-clinical-notes-area {
  min-height: 120px;
  padding: 12px;
  border: 1px solid var(--vw-border);
  border-radius: 0 0 var(--vw-radius) var(--vw-radius);
  outline: none;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--vw-text);
  background: var(--vw-card-bg);
}

.vw-clinical-notes-area:focus {
  border-color: var(--vw-primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.vw-notes-list {
  margin-top: 16px;
}

.vw-note-item {
  padding: 12px;
  border: 1px solid var(--vw-border);
  border-radius: var(--vw-radius);
  margin-bottom: 8px;
  background: var(--vw-bg-secondary);
}

.vw-note-item__header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
}

.vw-note-item__author {
  font-weight: 600;
  font-size: 0.8125rem;
  color: var(--vw-text);
}

.vw-note-item__date {
  font-size: 0.75rem;
  color: var(--vw-text-secondary);
}

.vw-note-item__content {
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--vw-text);
  white-space: pre-wrap;
}

/* ─── Prescription Card ─────────────────────────────────────────────────────── */
.vw-prescription-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.vw-prescription-card {
  border: 1px solid var(--vw-border);
  border-radius: var(--vw-radius);
  overflow: hidden;
}

.vw-prescription-card__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: var(--vw-bg-secondary);
  border-bottom: 1px solid var(--vw-border);
}

.vw-prescription-card__date {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--vw-text-secondary);
}

.vw-prescription-card__items {
  padding: 8px 12px;
}

.vw-prescription-item {
  padding: 6px 0;
  border-bottom: 1px solid var(--vw-border);
  font-size: 0.8125rem;
}

.vw-prescription-item:last-child {
  border-bottom: none;
}

.vw-prescription-item__name {
  font-weight: 600;
  color: var(--vw-text);
}

.vw-prescription-item__detail {
  color: var(--vw-text-secondary);
  margin-left: 6px;
}

.vw-prescription-item__duration {
  color: var(--vw-text-secondary);
  font-size: 0.75rem;
}

/* ─── Treatment Card ────────────────────────────────────────────────────────── */
.vw-treatment-card {
  border: 1px solid var(--vw-border);
  border-radius: var(--vw-radius);
  overflow: hidden;
}

.vw-treatment-card__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: var(--vw-bg-secondary);
  border-bottom: 1px solid var(--vw-border);
}

.vw-treatment-card__header h4 {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 600;
}

.vw-treatment-card__status {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--vw-success);
}

.vw-treatment-card__body {
  padding: 12px;
}

.vw-treatment-card__section {
  margin-bottom: 8px;
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--vw-text);
}

.vw-treatment-card__section strong {
  color: var(--vw-text);
}

/* ─── Follow-up Card ────────────────────────────────────────────────────────── */
.vw-followup-card {
  padding: 12px;
  background: var(--vw-bg-secondary);
  border: 1px solid var(--vw-border);
  border-radius: var(--vw-radius);
}

.vw-followup-card__date {
  font-weight: 700;
  font-size: 0.875rem;
  color: var(--vw-text);
  margin-bottom: 4px;
}

.vw-followup-card__reason {
  font-size: 0.8125rem;
  color: var(--vw-text-secondary);
}

.vw-followup-card__provider {
  font-size: 0.75rem;
  color: var(--vw-text-secondary);
  margin-top: 4px;
}

/* ─── Timeline ──────────────────────────────────────────────────────────────── */
.vw-timeline {
  position: relative;
  padding: 12px 0 12px 24px;
}

.vw-timeline-item {
  position: relative;
  padding-bottom: 20px;
  padding-left: 20px;
}

.vw-timeline-item:last-child {
  padding-bottom: 0;
}

.vw-timeline-dot {
  position: absolute;
  left: -24px;
  top: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--vw-primary);
  z-index: 1;
  border: 2px solid var(--vw-card-bg);
}

.vw-timeline-line {
  position: absolute;
  left: -19px;
  top: 16px;
  bottom: 0;
  width: 2px;
  background: var(--vw-border);
}

.vw-timeline-item:last-child .vw-timeline-line {
  display: none;
}

.vw-timeline-content {
  background: var(--vw-bg-secondary);
  border: 1px solid var(--vw-border);
  border-radius: var(--vw-radius);
  padding: 10px 12px;
}

.vw-timeline-content__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.vw-timeline-content__type {
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: capitalize;
}

.vw-timeline-content__time {
  font-size: 0.75rem;
  color: var(--vw-text-secondary);
}

.vw-timeline-content__body {
  font-size: 0.8125rem;
  color: var(--vw-text);
  line-height: 1.4;
}

.vw-timeline-content__user {
  font-size: 0.75rem;
  color: var(--vw-text-secondary);
  margin-top: 4px;
}

/* ─── Attachments Grid ──────────────────────────────────────────────────────── */
.vw-upload-zone {
  border: 2px dashed var(--vw-border);
  border-radius: var(--vw-radius-lg);
  padding: 32px;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--vw-transition), background var(--vw-transition);
  margin-bottom: 16px;
}

.vw-upload-zone:hover,
.vw-upload-zone--active {
  border-color: var(--vw-primary);
  background: rgba(99, 102, 241, 0.04);
}

.vw-upload-zone__icon {
  font-size: 2rem;
  margin-bottom: 8px;
}

.vw-upload-zone__text {
  font-size: 0.875rem;
  color: var(--vw-text-secondary);
}

.vw-attachments-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
}

.vw-attachment-thumb {
  border: 1px solid var(--vw-border);
  border-radius: var(--vw-radius);
  overflow: hidden;
  text-align: center;
  background: var(--vw-bg-secondary);
}

.vw-attachment-thumb img {
  width: 100%;
  height: 80px;
  object-fit: cover;
}

.vw-attachment-thumb__icon {
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
}

.vw-attachment-thumb__name {
  padding: 6px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--vw-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.vw-attachment-thumb__size {
  padding: 0 6px 6px;
  font-size: 0.6875rem;
  color: var(--vw-text-secondary);
}

/* ─── Quick Actions ─────────────────────────────────────────────────────────── */
.vw-quick-actions {
  padding-bottom: 4px;
}

.vw-actions-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* ─── Orders Section ────────────────────────────────────────────────────────── */
.vw-orders-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ─── AI Assistant ──────────────────────────────────────────────────────────── */
.vw-ai-assistant {
  border: 1px solid var(--vw-border);
  border-radius: var(--vw-radius);
  overflow: hidden;
}

.vw-ai-assistant__placeholder {
  padding: 24px;
  text-align: center;
}

.vw-ai-assistant__icon {
  font-size: 2rem;
  margin-bottom: 8px;
}

.vw-ai-assistant__text {
  font-size: 0.8125rem;
  color: var(--vw-text-secondary);
  margin-bottom: 12px;
}

.vw-ai-suggestion {
  padding: 10px 12px;
  border-bottom: 1px solid var(--vw-border);
  font-size: 0.8125rem;
}

.vw-ai-suggestion:last-child {
  border-bottom: none;
}

.vw-ai-suggestion__type {
  font-weight: 600;
  font-size: 0.75rem;
  color: var(--vw-primary);
  text-transform: uppercase;
  margin-bottom: 4px;
}

.vw-ai-suggestion__text {
  color: var(--vw-text);
  line-height: 1.4;
}

.vw-ai-suggestion__confidence {
  font-size: 0.6875rem;
  color: var(--vw-text-secondary);
  margin-top: 4px;
}

/* ─── Buttons ───────────────────────────────────────────────────────────────── */
.vw-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: var(--vw-radius);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--vw-transition);
  text-decoration: none;
  white-space: nowrap;
  font-family: inherit;
  line-height: 1.4;
}

.vw-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.vw-btn--primary {
  background: var(--vw-primary);
  color: #fff;
  border-color: var(--vw-primary);
}

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

.vw-btn--success {
  background: var(--vw-success);
  color: #fff;
  border-color: var(--vw-success);
}

.vw-btn--success:hover:not(:disabled) {
  background: #059669;
  border-color: #059669;
}

.vw-btn--danger {
  background: var(--vw-danger);
  color: #fff;
  border-color: var(--vw-danger);
}

.vw-btn--danger:hover:not(:disabled) {
  background: #dc2626;
  border-color: #dc2626;
}

.vw-btn--warning {
  background: var(--vw-warning);
  color: #fff;
  border-color: var(--vw-warning);
}

.vw-btn--outline {
  background: transparent;
  color: var(--vw-text);
  border-color: var(--vw-border);
}

.vw-btn--outline:hover:not(:disabled) {
  background: var(--vw-bg-secondary);
  border-color: var(--vw-text-secondary);
}

.vw-btn--sm {
  padding: 4px 10px;
  font-size: 0.8125rem;
}

.vw-btn--action {
  width: 100%;
  text-align: left;
  justify-content: flex-start;
  padding: 10px 12px;
  background: var(--vw-bg-secondary);
  border: 1px solid var(--vw-border);
}

.vw-btn--action:hover {
  background: #e2e8f0;
}

.vw-link {
  background: none;
  border: none;
  color: var(--vw-primary);
  cursor: pointer;
  font-size: inherit;
  padding: 0;
  text-decoration: underline;
}

.vw-link:hover {
  color: var(--vw-primary-hover);
}

.vw-btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.125rem;
  color: var(--vw-text-secondary);
  padding: 4px;
  line-height: 1;
  border-radius: 4px;
  transition: color var(--vw-transition), background var(--vw-transition);
}

.vw-btn-icon:hover {
  color: var(--vw-danger);
  background: #fef2f2;
}

/* ─── Badges ────────────────────────────────────────────────────────────────── */
.vw-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1;
}

.vw-badge--sm {
  font-size: 0.6875rem;
  padding: 2px 6px;
}

/* ─── Stat Mini ─────────────────────────────────────────────────────────────── */
.vw-stat-mini {
  font-size: 0.75rem;
  color: var(--vw-text-secondary);
  white-space: nowrap;
}

.vw-stat-mini strong {
  color: var(--vw-text);
}

/* ─── Empty State ───────────────────────────────────────────────────────────── */
.vw-empty {
  text-align: center;
  padding: 32px 16px;
  color: var(--vw-text-secondary);
  font-size: 0.875rem;
}

.vw-empty--sm {
  padding: 12px 8px;
  font-size: 0.8125rem;
}

.vw-empty__icon {
  font-size: 2rem;
  margin-bottom: 8px;
  opacity: 0.5;
}

/* ─── Spinner ───────────────────────────────────────────────────────────────── */
.vw-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px;
  gap: 12px;
  color: var(--vw-text-secondary);
  font-size: 0.875rem;
}

.vw-spinner__ring {
  width: 32px;
  height: 32px;
  border: 3px solid var(--vw-border);
  border-top-color: var(--vw-primary);
  border-radius: 50%;
  animation: vw-spin 0.8s linear infinite;
}

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

@keyframes vw-slide-in {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ─── Table ─────────────────────────────────────────────────────────────────── */
.vw-table-wrapper {
  background: var(--vw-card-bg);
  border: 1px solid var(--vw-border);
  border-radius: var(--vw-radius-lg);
  overflow-x: auto;
  box-shadow: var(--vw-shadow);
  margin-bottom: 16px;
}

.vw-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.vw-table thead {
  background: var(--vw-bg-secondary);
  border-bottom: 2px solid var(--vw-border);
}

.vw-table th {
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  font-size: 0.8125rem;
  color: var(--vw-text-secondary);
  white-space: nowrap;
}

.vw-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--vw-border);
  vertical-align: middle;
}

.vw-table-row {
  cursor: pointer;
  transition: background var(--vw-transition);
}

.vw-table-row:hover {
  background: rgba(99, 102, 241, 0.04);
}

.vw-table-row:last-child td {
  border-bottom: none;
}

.vw-patient-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.vw-patient-cell strong {
  color: var(--vw-text);
}

.vw-text-muted {
  color: var(--vw-text-secondary);
  font-size: 0.75rem;
}

.vw-table-actions {
  display: flex;
  gap: 4px;
}

/* ─── Pagination ────────────────────────────────────────────────────────────── */
.vw-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 12px;
}

.vw-pagination-info {
  font-size: 0.8125rem;
  color: var(--vw-text-secondary);
}

/* ─── Section ───────────────────────────────────────────────────────────────── */
.vw-section {
  margin-bottom: 4px;
}

.vw-section__title {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--vw-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin: 0 0 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--vw-border);
}

/* ─── Bottom Panel ──────────────────────────────────────────────────────────── */
.vw-bottom-panel {
  background: var(--vw-card-bg);
  border: 1px solid var(--vw-border);
  border-radius: var(--vw-radius-lg);
  padding: 16px;
  box-shadow: var(--vw-shadow);
}

/* ─── Modal ─────────────────────────────────────────────────────────────────── */
.vw-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 16px;
  animation: vw-fade-in 0.2s ease;
}

@keyframes vw-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.vw-modal {
  background: var(--vw-card-bg);
  border-radius: var(--vw-radius-lg);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  animation: vw-modal-in 0.2s ease;
}

@keyframes vw-modal-in {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.vw-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--vw-border);
}

.vw-modal__title {
  font-size: 1.125rem;
  font-weight: 700;
  margin: 0;
  color: var(--vw-text);
}

.vw-modal__close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--vw-text-secondary);
  padding: 4px;
  line-height: 1;
  border-radius: 4px;
  transition: color var(--vw-transition);
}

.vw-modal__close:hover {
  color: var(--vw-danger);
}

.vw-modal__body {
  padding: 20px;
}

/* ─── Search Results ────────────────────────────────────────────────────────── */
.vw-search-result {
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--vw-border);
  font-size: 0.8125rem;
  transition: background var(--vw-transition);
}

.vw-search-result:hover {
  background: var(--vw-bg-secondary);
}

.vw-search-result strong {
  display: block;
  color: var(--vw-text);
}

.vw-search-result--empty {
  cursor: default;
  color: var(--vw-text-secondary);
  text-align: center;
}

/* ---- Patient Search Results Dropdown ---- */
.vw-patient-search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
  z-index: 100;
  max-height: 260px;
  overflow: hidden;
  display: none;
}
.vw-patient-search-results.open {
  display: block;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Dark Mode
   ═══════════════════════════════════════════════════════════════════════════════ */
[data-theme="dark"] :root {
  --vw-card-bg: #1e1e2e;
  --vw-border: #313244;
  --vw-text: #cdd6f4;
  --vw-text-secondary: #6c7086;
  --vw-bg-secondary: #181825;
  --vw-primary: #89b4fa;
  --vw-primary-hover: #74c7ec;
  --vw-success: #a6e3a1;
  --vw-danger: #f38ba8;
  --vw-warning: #f9e2af;
  --vw-info: #89dceb;
}

[data-theme="dark"] .vw-alert-card {
  background: #45242b;
  border-color: #5a2d37;
  border-left-color: var(--vw-danger);
}

[data-theme="dark"] .vw-alert-card__type {
  color: var(--vw-danger);
}

[data-theme="dark"] .vw-alert-card__detail {
  color: #f5a0b8;
}

[data-theme="dark"] .vw-table thead {
  background: var(--tdl-surface);
}

[data-theme="dark"] .vw-table-row:hover {
  background: rgba(137, 180, 250, 0.06);
}

[data-theme="dark"] .vw-diagnosis-suggestion:hover {
  background: var(--tdl-hover);
}

[data-theme="dark"] .vw-prev-visit:hover {
  background: var(--tdl-hover);
}

[data-theme="dark"] .vw-upload-zone {
  border-color: var(--tdl-border);
}

[data-theme="dark"] .vw-upload-zone:hover,
[data-theme="dark"] .vw-upload-zone--active {
  border-color: var(--vw-primary);
  background: rgba(137, 180, 250, 0.06);
}

[data-theme="dark"] .vw-btn--action:hover {
  background: var(--tdl-hover);
}

[data-theme="dark"] .vw-btn--outline:hover:not(:disabled) {
  background: var(--tdl-hover);
}

[data-theme="dark"] .vw-modal {
  background: var(--tdl-card);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   RTL Support
   ═══════════════════════════════════════════════════════════════════════════════ */
[dir="rtl"] .vw-container {
  direction: rtl;
}

[dir="rtl"] .vw-header {
  flex-direction: row-reverse;
}

[dir="rtl"] .vw-filters__row {
  flex-direction: row-reverse;
}

[dir="rtl"] .vw-filter-group {
  text-align: right;
}

[dir="rtl"] .vw-tabs {
  flex-direction: row-reverse;
}

[dir="rtl"] .vw-tab {
  text-align: right;
}

[dir="rtl"] .vw-tab--active {
  border-bottom-color: var(--vw-primary);
}

[dir="rtl"] .vw-diagnosis-controls {
  flex-direction: row-reverse;
}

[dir="rtl"] .vw-diagnosis-item {
  flex-direction: row-reverse;
}

[dir="rtl"] .vw-diagnosis-item__info {
  flex-direction: row-reverse;
}

[dir="rtl"] .vw-visit-header {
  flex-direction: row-reverse;
}

[dir="rtl"] .vw-visit-header__meta {
  flex-direction: row-reverse;
}

[dir="rtl"] .vw-patient-card {
  flex-direction: row-reverse;
}

[dir="rtl"] .vw-alert-card {
  flex-direction: row-reverse;
  border-left: none;
  border-right: 3px solid var(--vw-danger);
}

[dir="rtl"] .vw-timeline {
  padding-left: 0;
  padding-right: 24px;
}

[dir="rtl"] .vw-timeline-item {
  padding-left: 0;
  padding-right: 20px;
}

[dir="rtl"] .vw-timeline-dot {
  left: auto;
  right: -24px;
}

[dir="rtl"] .vw-timeline-line {
  left: auto;
  right: -19px;
}

[dir="rtl"] .vw-prev-visit {
  flex-direction: row-reverse;
}

[dir="rtl"] .vw-note-item__header {
  flex-direction: row-reverse;
}

[dir="rtl"] .vw-prescription-card__header {
  flex-direction: row-reverse;
}

[dir="rtl"] .vw-treatment-card__header {
  flex-direction: row-reverse;
}

[dir="rtl"] .vw-table th {
  text-align: right;
}

[dir="rtl"] .vw-table td {
  text-align: right;
}

[dir="rtl"] .vw-btn--action {
  text-align: right;
  justify-content: flex-end;
}

[dir="rtl"] .vw-pagination {
  flex-direction: row-reverse;
}

[dir="rtl"] .vw-header__title,
[dir="rtl"] .vw-header__subtitle {
  text-align: right;
}

[dir="rtl"] .vw-timeline-content__header {
  flex-direction: row-reverse;
}

[dir="rtl"] .vw-alert-card__icon {
  order: 1;
}

[dir="rtl"] .vw-patient-card__avatar {
  margin-right: 0;
  margin-left: 8px;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Responsive: ≤1200px — Stack panels vertically
   ═══════════════════════════════════════════════════════════════════════════════ */
@media (max-width: 1200px) {
  .vw-workspace {
    grid-template-columns: 1fr;
  }

  .vw-panel {
    max-height: none;
  }

  .vw-center-panel {
    order: -1;
  }

  .vw-left-panel {
    order: 0;
  }

  .vw-right-panel {
    order: 1;
  }

  .vw-vitals-grid {
    grid-template-columns: 1fr;
  }

  .vw-form-row {
    grid-template-columns: 1fr;
  }

  .vw-filters__row {
    flex-direction: column;
  }

  .vw-filter-group {
    min-width: 100%;
  }

  .vw-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .vw-header__right {
    width: 100%;
  }

  .vw-header__right .vw-btn {
    width: 100%;
  }

  .vw-table-wrapper {
    overflow-x: auto;
  }

  .vw-attachments-grid {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  }

  .vw-diagnosis-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .vw-modal {
    max-width: 100%;
    margin: 8px;
  }
}

@media (max-width: 768px) {
  .vw-container {
    padding: 8px;
  }

  .vw-tabs {
    padding: 0 8px;
  }

  .vw-tab {
    padding: 10px 10px;
    font-size: 0.8125rem;
  }

  .vw-tab-content {
    padding: 12px;
  }

  .vw-visit-header {
    flex-direction: column;
    padding: 12px;
  }

  .vw-patient-card {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .vw-patient-card__meta {
    justify-content: center;
  }

  .vw-patient-card__contact {
    align-items: center;
  }

  .vw-vitals-mini {
    grid-template-columns: 1fr;
  }

  .vw-actions-list {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .vw-btn--action {
    flex: 1;
    min-width: calc(50% - 3px);
    justify-content: center;
  }
}
