/*
 * E11-1.12 Web Doctor Workbench Final Layout Fix Overlay
 * This stylesheet intentionally overrides E11-1.8/1.9/1.10/1.11 residual styles.
 */
:root {
  --e1112-rail-width: 376px;
  --e1112-rail-right: 28px;
  --e1112-rail-gap: 18px;
  --e1112-blue: #2563eb;
  --e1112-blue-soft: #eff6ff;
  --e1112-green: #059669;
  --e1112-border: #d7e7ff;
  --e1112-border-strong: #bfdbfe;
  --e1112-bg: #f8fbff;
  --e1112-text: #0f2a4a;
  --e1112-muted: #64748b;
  --e1112-danger: #e11d48;
  --e1112-warn: #b45309;
}

body.e11-1-12-final-layout-fix {
  overflow-x: hidden !important;
}

/* 1. Full-width fallback: old overlay shrink rules must not affect non-consult pages. */
body.e11-1-12-final-layout-fix.e1112-consult-inactive .e10-flow-scroll-layout,
body.e11-1-12-final-layout-fix.e1112-consult-inactive .e10-unified-layout,
body.e11-1-12-final-layout-fix.e1112-consult-inactive .e10-unified-main,
body.e11-1-12-final-layout-fix.e1112-consult-inactive .e1110-main-safe,
body.e11-1-12-final-layout-fix.e1112-consult-inactive .e1111-main-safe,
body.e11-1-12-final-layout-fix.e1112-consult-inactive .e1112-main-safe {
  width: auto !important;
  max-width: none !important;
  min-width: 0 !important;
  padding-right: 0 !important;
  margin-right: 0 !important;
  overflow: visible !important;
}

body.e11-1-12-final-layout-fix.e1112-consult-inactive .e10-flow-side {
  position: static !important;
  width: auto !important;
  max-width: none !important;
  height: auto !important;
  max-height: none !important;
  right: auto !important;
  top: auto !important;
  bottom: auto !important;
}

/* 2. Consult page: fixed right rail, middle main calculated by JS to stop before rail. */
body.e11-1-12-final-layout-fix.e1112-consult-active .e10-flow-scroll-layout,
body.e11-1-12-final-layout-fix.e1112-consult-active .e1112-layout-safe {
  display: block !important;
  grid-template-columns: none !important;
  position: static !important;
  box-sizing: border-box !important;
  min-width: 0 !important;
  max-width: none !important;
  padding-right: 0 !important;
  overflow: visible !important;
}

body.e11-1-12-final-layout-fix.e1112-consult-active .e10-unified-main,
body.e11-1-12-final-layout-fix.e1112-consult-active .e1112-main-safe {
  box-sizing: border-box !important;
  min-width: 0 !important;
  overflow: visible !important;
}

body.e11-1-12-final-layout-fix.e1112-consult-active .e10-unified-main > *,
body.e11-1-12-final-layout-fix.e1112-consult-active .e1112-main-safe > * {
  max-width: 100% !important;
  box-sizing: border-box !important;
}

body.e11-1-12-final-layout-fix.e1112-consult-active .e10-flow-side,
body.e11-1-12-final-layout-fix.e1112-consult-active .e1112-right-rail {
  position: fixed !important;
  z-index: 90 !important;
  top: 86px !important;
  right: var(--e1112-rail-right) !important;
  bottom: 22px !important;
  width: var(--e1112-rail-width) !important;
  min-width: 0 !important;
  max-width: var(--e1112-rail-width) !important;
  height: auto !important;
  max-height: none !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 12px !important;
  align-self: auto !important;
  pointer-events: auto !important;
  transform: none !important;
  overflow: visible !important;
}

body.e11-1-12-final-layout-fix.e1112-consult-active .e10-flow-side::before {
  content: "" !important;
  position: absolute !important;
  inset: -10px !important;
  z-index: -1 !important;
  border-radius: 22px !important;
  background: linear-gradient(180deg, rgba(248, 252, 255, .92), rgba(255, 255, 255, .78)) !important;
  box-shadow: 0 18px 42px rgba(15, 45, 85, .09) !important;
  pointer-events: none !important;
}

/* 3. Right rail folding: exactly one button per card, no old duplicate buttons. */
body.e11-1-12-final-layout-fix .e1110-fold-row,
body.e11-1-12-final-layout-fix .e1110-fold-btn,
body.e11-1-12-final-layout-fix .e1111-right-control {
  display: none !important;
}

body.e11-1-12-final-layout-fix.e1112-consult-active .e1112-rail-card {
  position: relative !important;
  box-sizing: border-box !important;
  min-width: 0 !important;
  width: 100% !important;
  max-width: 100% !important;
  border-radius: 16px !important;
  overflow: hidden !important;
}

body.e11-1-12-final-layout-fix.e1112-consult-active .e10-flow-side .clinical-reference-panel.e1112-rail-card {
  flex: 0 0 28% !important;
  min-height: 112px !important;
  max-height: 34vh !important;
  display: flex !important;
  flex-direction: column !important;
  border: 1px solid #ccebdd !important;
  background: #f8fffb !important;
}

body.e11-1-12-final-layout-fix.e1112-consult-active .e10-flow-side .ai-assist-placeholder.e1112-rail-card {
  flex: 1 1 auto !important;
  min-height: 300px !important;
  max-height: none !important;
  display: flex !important;
  flex-direction: column !important;
  border: 1px solid #d8e6ff !important;
  background: #ffffff !important;
}

body.e11-1-12-final-layout-fix.e1112-consult-active .e1112-rail-card[data-e1112-collapsed="true"] {
  flex: 0 0 66px !important;
  min-height: 66px !important;
  max-height: 66px !important;
  overflow: hidden !important;
}

body.e11-1-12-final-layout-fix.e1112-consult-active .e1112-fold-control {
  position: absolute !important;
  top: 10px !important;
  right: 10px !important;
  z-index: 35 !important;
  display: inline-flex !important;
  align-items: center !important;
  pointer-events: auto !important;
}

body.e11-1-12-final-layout-fix.e1112-consult-active .e1112-fold-btn {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  min-width: 52px !important;
  height: 30px !important;
  padding: 0 12px !important;
  border: 1px solid var(--e1112-border-strong) !important;
  border-radius: 999px !important;
  background: #ffffff !important;
  color: #1d4ed8 !important;
  font-size: 13px !important;
  font-weight: 800 !important;
  line-height: 1 !important;
  white-space: nowrap !important;
  cursor: pointer !important;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.08) !important;
}

body.e11-1-12-final-layout-fix.e1112-consult-active .e1112-fold-btn:hover {
  background: var(--e1112-blue-soft) !important;
}

body.e11-1-12-final-layout-fix.e1112-consult-active .e10-flow-side .clinical-reference-list {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  padding-right: 5px !important;
  scrollbar-gutter: stable !important;
}

/* 4. AI right card must remain readable instead of becoming compressed pills. */
body.e11-1-12-final-layout-fix.e1112-consult-active .e1112-ai-readable {
  overflow-y: auto !important;
  overflow-x: hidden !important;
  scrollbar-gutter: stable !important;
}

body.e11-1-12-final-layout-fix.e1112-consult-active .e1112-ai-readable .ai-assist-header {
  flex: 0 0 auto !important;
  margin-bottom: 8px !important;
  padding-right: 62px !important;
}

body.e11-1-12-final-layout-fix.e1112-consult-active .e1112-ai-module-card,
body.e11-1-12-final-layout-fix.e1112-consult-active .e1112-ai-readable .e1110-ai-module-card,
body.e11-1-12-final-layout-fix.e1112-consult-active .e1112-ai-readable .e1111-ai-readable-card {
  height: auto !important;
  min-height: 96px !important;
  max-height: none !important;
  overflow: visible !important;
  white-space: normal !important;
  line-height: 1.55 !important;
}

body.e11-1-12-final-layout-fix.e1112-consult-active .e1112-ai-readable * {
  min-width: 0 !important;
  max-width: 100% !important;
  overflow-wrap: anywhere !important;
  white-space: normal !important;
}

body.e11-1-12-final-layout-fix.e1112-consult-active .e1112-ai-readable button,
body.e11-1-12-final-layout-fix.e1112-consult-active .e1112-ai-readable .iw-btn,
body.e11-1-12-final-layout-fix.e1112-consult-active .e1112-ai-readable [role="button"] {
  flex-shrink: 0 !important;
  white-space: nowrap !important;
}

/* 5. Prescription detail: real base classes are prescription-item-list / prescription-item-row. */
body.e11-1-12-final-layout-fix .e1112-prescription-items-panel,
body.e11-1-12-final-layout-fix .prescription-items-panel {
  box-sizing: border-box !important;
  width: 100% !important;
  max-width: 100% !important;
  overflow: hidden !important;
}

body.e11-1-12-final-layout-fix .e1112-prescription-item-list,
body.e11-1-12-final-layout-fix .prescription-items-panel .prescription-item-list,
body.e11-1-12-final-layout-fix .prescription-items-panel .e1110-prescription-detail-grid,
body.e11-1-12-final-layout-fix .prescription-items-panel .e11-rx-detail-v111-list,
body.e11-1-12-final-layout-fix .prescription-items-panel .e11-rx-detail-v19-list {
  display: grid !important;
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  gap: 10px !important;
  align-items: stretch !important;
  width: 100% !important;
  max-width: 100% !important;
  overflow: visible !important;
}

body.e11-1-12-final-layout-fix .e1112-prescription-item-card,
body.e11-1-12-final-layout-fix .prescription-items-panel .prescription-item-row,
body.e11-1-12-final-layout-fix .prescription-items-panel .prescription-item-card,
body.e11-1-12-final-layout-fix .prescription-items-panel .e1110-prescription-detail-card,
body.e11-1-12-final-layout-fix .prescription-items-panel .e11-rx-detail-v111-card,
body.e11-1-12-final-layout-fix .prescription-items-panel .e11-rx-detail-v19-card {
  position: relative !important;
  box-sizing: border-box !important;
  width: 100% !important;
  min-width: 0 !important;
  max-width: 100% !important;
  min-height: 116px !important;
  height: auto !important;
  margin: 0 !important;
  padding: 12px 32px 12px 12px !important;
  border: 1px solid var(--e1112-border) !important;
  border-radius: 14px !important;
  background: #f8fbff !important;
  box-shadow: none !important;
  overflow: hidden !important;
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) 72px 52px minmax(112px, 0.95fr) !important;
  grid-template-areas:
    "name name name name"
    "dose unit usage usage" !important;
  gap: 8px 8px !important;
  align-items: end !important;
}

body.e11-1-12-final-layout-fix .e1112-prescription-item-card *,
body.e11-1-12-final-layout-fix .prescription-items-panel .prescription-item-row *,
body.e11-1-12-final-layout-fix .prescription-items-panel .prescription-item-card *,
body.e11-1-12-final-layout-fix .prescription-items-panel .e1110-prescription-detail-card *,
body.e11-1-12-final-layout-fix .prescription-items-panel .e11-rx-detail-v111-card *,
body.e11-1-12-final-layout-fix .prescription-items-panel .e11-rx-detail-v19-card * {
  box-sizing: border-box !important;
  min-width: 0 !important;
  max-width: 100% !important;
}

body.e11-1-12-final-layout-fix .e1112-prescription-item-name,
body.e11-1-12-final-layout-fix .prescription-items-panel .prescription-item-name {
  grid-area: name !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 2px !important;
  min-width: 0 !important;
  padding-right: 24px !important;
}

body.e11-1-12-final-layout-fix .prescription-items-panel .prescription-item-name strong {
  font-size: 15px !important;
  font-weight: 900 !important;
  color: var(--e1112-text) !important;
  line-height: 1.35 !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

body.e11-1-12-final-layout-fix .prescription-items-panel .prescription-item-name span {
  color: var(--e1112-muted) !important;
  font-size: 12px !important;
  line-height: 1.3 !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

body.e11-1-12-final-layout-fix .prescription-items-panel label,
body.e11-1-12-final-layout-fix .e1112-prescription-item-field {
  display: flex !important;
  flex-direction: column !important;
  gap: 4px !important;
  margin: 0 !important;
  color: var(--e1112-text) !important;
  font-size: 12px !important;
  font-weight: 800 !important;
  line-height: 1.2 !important;
}

body.e11-1-12-final-layout-fix .prescription-items-panel .e1112-dose-field { grid-area: dose !important; }
body.e11-1-12-final-layout-fix .prescription-items-panel .e1112-unit-field { grid-area: unit !important; }
body.e11-1-12-final-layout-fix .prescription-items-panel .e1112-usage-field { grid-area: usage !important; }

body.e11-1-12-final-layout-fix .prescription-items-panel input,
body.e11-1-12-final-layout-fix .prescription-items-panel select,
body.e11-1-12-final-layout-fix .prescription-items-panel textarea {
  width: 100% !important;
  min-width: 0 !important;
  max-width: 100% !important;
  height: 34px !important;
  min-height: 34px !important;
  padding: 6px 9px !important;
  border-radius: 9px !important;
  font-size: 13px !important;
  line-height: 20px !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

body.e11-1-12-final-layout-fix .e1112-delete-item-btn,
body.e11-1-12-final-layout-fix .prescription-items-panel [data-prescription-action="remove-item"],
body.e11-1-12-final-layout-fix .prescription-items-panel .e1110-card-x-btn,
body.e11-1-12-final-layout-fix .prescription-items-panel .e11-rx-detail-v111-delete,
body.e11-1-12-final-layout-fix .prescription-items-panel .e11-rx-detail-v19-delete {
  position: absolute !important;
  top: 8px !important;
  right: 8px !important;
  z-index: 6 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 24px !important;
  height: 24px !important;
  min-width: 24px !important;
  max-width: 24px !important;
  padding: 0 !important;
  border-radius: 999px !important;
  border: 1px solid #fecdd3 !important;
  background: #fff1f2 !important;
  color: var(--e1112-danger) !important;
  font-size: 16px !important;
  font-weight: 900 !important;
  line-height: 1 !important;
  white-space: nowrap !important;
}

body.e11-1-12-final-layout-fix .e1112-delete-item-btn:hover,
body.e11-1-12-final-layout-fix .prescription-items-panel [data-prescription-action="remove-item"]:hover {
  background: #ffe4e6 !important;
}

@media (max-width: 1680px) {
  body.e11-1-12-final-layout-fix .e1112-prescription-item-list,
  body.e11-1-12-final-layout-fix .prescription-items-panel .prescription-item-list,
  body.e11-1-12-final-layout-fix .prescription-items-panel .e1110-prescription-detail-grid,
  body.e11-1-12-final-layout-fix .prescription-items-panel .e11-rx-detail-v111-list,
  body.e11-1-12-final-layout-fix .prescription-items-panel .e11-rx-detail-v19-list {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}

@media (max-width: 1260px) {
  body.e11-1-12-final-layout-fix .e1112-prescription-item-list,
  body.e11-1-12-final-layout-fix .prescription-items-panel .prescription-item-list,
  body.e11-1-12-final-layout-fix .prescription-items-panel .e1110-prescription-detail-grid,
  body.e11-1-12-final-layout-fix .prescription-items-panel .e11-rx-detail-v111-list,
  body.e11-1-12-final-layout-fix .prescription-items-panel .e11-rx-detail-v19-list {
    grid-template-columns: 1fr !important;
  }
}

/* 6. Prescription risk compact. */
body.e11-1-12-final-layout-fix .e1112-risk-panel,
body.e11-1-12-final-layout-fix .prescription-safety-panel {
  box-sizing: border-box !important;
  max-width: 100% !important;
  overflow: hidden !important;
  border: 1px solid #dbeafe !important;
  border-radius: 16px !important;
  background: #f8fbff !important;
  padding: 12px 14px !important;
  margin-top: 12px !important;
}

body.e11-1-12-final-layout-fix .prescription-safety-title-row {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 12px !important;
  padding: 8px 10px !important;
  border: 1px solid #bfdbfe !important;
  border-radius: 12px !important;
  background: #ffffff !important;
}

body.e11-1-12-final-layout-fix .prescription-safety-title-row p,
body.e11-1-12-final-layout-fix .prescription-safety-snapshot {
  font-size: 12px !important;
  line-height: 1.45 !important;
  color: var(--e1112-muted) !important;
}

body.e11-1-12-final-layout-fix .e1112-risk-toggle {
  flex: 0 0 auto !important;
  height: 30px !important;
  min-width: 76px !important;
  padding: 0 12px !important;
  border: 1px solid #bfdbfe !important;
  border-radius: 999px !important;
  background: #eff6ff !important;
  color: #1d4ed8 !important;
  font-size: 13px !important;
  font-weight: 800 !important;
  cursor: pointer !important;
  white-space: nowrap !important;
}

body.e11-1-12-final-layout-fix .e1112-risk-panel[data-e1112-risk-expanded="false"] .prescription-safety-group-wrap,
body.e11-1-12-final-layout-fix .e1112-risk-panel[data-e1112-risk-expanded="false"] .prescription-safety-warning,
body.e11-1-12-final-layout-fix .e1112-risk-panel[data-e1112-risk-expanded="false"] .prescription-safety-group,
body.e11-1-12-final-layout-fix .e1112-risk-panel[data-e1112-risk-expanded="false"] .e1112-risk-card {
  display: none !important;
}

body.e11-1-12-final-layout-fix .prescription-safety-group-wrap {
  display: grid !important;
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  gap: 10px !important;
  max-height: 360px !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  margin-top: 10px !important;
  padding-right: 4px !important;
}

body.e11-1-12-final-layout-fix .prescription-safety-warning,
body.e11-1-12-final-layout-fix .prescription-safety-group,
body.e11-1-12-final-layout-fix .e1112-risk-card {
  box-sizing: border-box !important;
  min-width: 0 !important;
  max-width: 100% !important;
  min-height: 0 !important;
  height: auto !important;
  padding: 10px !important;
  border-radius: 12px !important;
  border: 1px solid #bfdbfe !important;
  background: #ffffff !important;
  overflow: hidden !important;
  font-size: 12px !important;
  line-height: 1.48 !important;
}

body.e11-1-12-final-layout-fix .prescription-safety-warning *,
body.e11-1-12-final-layout-fix .prescription-safety-group *,
body.e11-1-12-final-layout-fix .e1112-risk-card * {
  min-width: 0 !important;
  max-width: 100% !important;
  overflow-wrap: anywhere !important;
}

@media (max-width: 1680px) {
  body.e11-1-12-final-layout-fix .prescription-safety-group-wrap {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}

@media (max-width: 1280px) {
  body.e11-1-12-final-layout-fix.e1112-consult-active .e10-flow-scroll-layout,
  body.e11-1-12-final-layout-fix.e1112-consult-active .e1112-layout-safe {
    display: grid !important;
    grid-template-columns: 1fr !important;
  }
  body.e11-1-12-final-layout-fix.e1112-consult-active .e10-unified-main,
  body.e11-1-12-final-layout-fix.e1112-consult-active .e1112-main-safe {
    width: auto !important;
    max-width: none !important;
  }
  body.e11-1-12-final-layout-fix.e1112-consult-active .e10-flow-side,
  body.e11-1-12-final-layout-fix.e1112-consult-active .e1112-right-rail {
    position: static !important;
    right: auto !important;
    top: auto !important;
    bottom: auto !important;
    width: auto !important;
    max-width: none !important;
    height: auto !important;
    margin-top: 14px !important;
  }
  body.e11-1-12-final-layout-fix.e1112-consult-active .e10-flow-side::before {
    display: none !important;
  }
  body.e11-1-12-final-layout-fix .prescription-safety-group-wrap {
    grid-template-columns: 1fr !important;
  }
}
