/* Inpatient EMR Generation component styles (scoped with iem-) */

.iem-root {
  font-family: var(--font-functions-body, system-ui, -apple-system, BlinkMacSystemFont, sans-serif);
  color: var(--color-text, #4d5d6d);
  background: var(--color-white, #ffffff);
  border: 1px solid var(--color-border, #e7ebee);
  border-radius: 12px;
  padding: 18px 18px 22px;
  box-shadow: 0 18px 45px rgba(15, 35, 52, 0.06);
  width: 100%;
  box-sizing: border-box;
}

.page-functions #panel-inpatientemr .iem-root {
  margin: 0 auto;
}

.iem-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.iem-title {
  font-family: var(--font-functions-heading, 'Merriweather', Georgia, serif);
  font-size: 18px;
  font-weight: 700;
  color: var(--color-heading, #102136);
  margin: 0;
}

.iem-subtitle {
  margin: 4px 0 0;
  font-size: 13px;
  color: #6b7280;
}

.iem-tabs {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.iem-tab {
  border: 1px solid var(--color-border, #e7ebee);
  background: #fff;
  color: #5a6478;
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.18s, border-color 0.18s, color 0.18s, transform 0.12s;
}

.iem-tab:hover {
  transform: translateY(-1px);
}

.iem-tab--active {
  background: rgba(116, 86, 241, 0.12);
  border-color: rgba(116, 86, 241, 0.55);
  color: var(--color-primary, #7456f1);
}

.iem-card {
  background: var(--color-bg-lighter, #fbfbfc);
  border: 1px solid var(--color-border, #e7ebee);
  border-radius: 12px;
  padding: 14px;
}

.iem-asr-card {
  margin-bottom: 16px;
}

.iem-asr-input-row {
  display: flex;
  align-items: stretch;
  gap: 12px;
}

.iem-asr-viz {
  flex: 0 0 20%;
  width: 20%;
  min-width: 120px;
  height: 90px;
  display: block;
  border-radius: 12px;
  background: rgba(116, 86, 241, 0.03);
  border: 1px solid rgba(229, 231, 235, 0.9);
  margin-bottom: 0;
}

.iem-asr-input-row .iem-textarea {
  flex: 1;
  min-width: 0;
}

.iem-asr-viz--recording {
  background: rgba(116, 86, 241, 0.06);
}

.iem-asr-viz--paused {
  background: rgba(245, 158, 11, 0.05);
}

.iem-asr-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.iem-asr-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #374151;
  font-weight: 600;
}

.iem-asr-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #9ca3af;
  flex-shrink: 0;
}

.iem-asr-dot--recording {
  background: #ef4444;
  box-shadow: 0 0 0 6px rgba(239, 68, 68, 0.15);
}

.iem-asr-dot--paused {
  background: #f59e0b;
}

@media (max-width: 700px) {
  .iem-asr-input-row {
    flex-direction: column;
  }
  .iem-asr-viz {
    width: 100%;
    min-width: 0;
    flex: 0 0 auto;
    height: 80px;
  }
}

.iem-textarea {
  width: 100%;
  border: 1px solid var(--color-border, #e7ebee);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  line-height: 1.6;
  background: #fff;
  color: inherit;
  min-height: 90px;
  resize: vertical;
  box-sizing: border-box;
}

.iem-textarea:focus {
  outline: none;
  border-color: var(--color-primary, #7456f1);
  box-shadow: 0 0 0 2px rgba(116, 86, 241, 0.15);
}

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

.iem-btn {
  border: 1px solid var(--color-border, #e7ebee);
  background: #fff;
  color: #374151;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  transition: background 0.18s, border-color 0.18s, transform 0.12s, opacity 0.18s;
}

.iem-btn:hover {
  background: rgba(116, 86, 241, 0.06);
  border-color: rgba(116, 86, 241, 0.35);
  transform: translateY(-1px);
}

.iem-btn:disabled {
  cursor: not-allowed;
  opacity: 0.6;
  transform: none;
}

.iem-btn--primary {
  background: linear-gradient(135deg, #7c5af3 0%, #5e3fde 100%);
  border-color: transparent;
  color: #fff;
}

.iem-btn--danger {
  background: #fff;
  border-color: rgba(239, 68, 68, 0.45);
  color: #b91c1c;
}

.iem-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 18px;
  margin-top: 12px;
}

.iem-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.iem-label {
  font-size: 13px;
  font-weight: 800;
  color: #334155;
}

.iem-input,
.iem-select {
  border: 1px solid var(--color-border, #e7ebee);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: inherit;
  box-sizing: border-box;
  min-width: 0;
}

.iem-input:focus,
.iem-select:focus {
  outline: none;
  border-color: var(--color-primary, #7456f1);
  box-shadow: 0 0 0 2px rgba(116, 86, 241, 0.15);
}

.iem-accordion {
  margin-top: 10px;
  border-top: 1px dashed rgba(229, 231, 235, 0.9);
  padding-top: 10px;
}

.iem-accordion-item {
  margin-bottom: 10px;
}

.iem-accordion-header {
  width: 100%;
  border: 1px solid rgba(229, 231, 235, 0.9);
  background: rgba(116, 86, 241, 0.04);
  border-radius: 10px;
  padding: 9px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
}

.iem-accordion-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 900;
  color: #111827;
}

.iem-accordion-toggle {
  font-size: 12px;
  color: #6b7280;
  font-weight: 700;
}

.iem-accordion-body {
  margin-top: 10px;
  padding: 12px;
  border: 1px solid rgba(229, 231, 235, 0.9);
  border-radius: 10px;
  background: #fff;
}

.iem-admission-field {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: #ffffff;
  border: 1px solid rgba(229, 231, 235, 0.9);
  border-radius: 10px;
  padding: 10px 12px;
  box-sizing: border-box;
  margin-bottom: 10px;
}

.iem-admission-label {
  flex: 0 0 26px;
  max-width: 26px;
  background: rgba(116, 86, 241, 0.06);
  border: 1px dashed rgba(116, 86, 241, 0.35);
  border-radius: 8px;
  padding: 6px 2px;
  color: #111827;
  font-size: 13px;
  font-weight: 1000;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  letter-spacing: 0.02em;
  display: inline-block;
  white-space: normal;
  overflow-wrap: break-word;
  word-break: break-word;
  line-break: normal;
  max-height: 140px;
  overflow: hidden;
}

.iem-admission-field .iem-input,
.iem-admission-field .iem-textarea {
  flex: 1;
  min-width: 0;
}

@media (max-width: 800px) {
  .iem-admission-field {
    flex-direction: column;
    align-items: stretch;
  }
  .iem-admission-label {
    writing-mode: horizontal-tb;
    max-width: none;
    flex: 0 0 auto;
    width: 100%;
    border: 1px solid rgba(116, 86, 241, 0.35);
    padding: 8px 10px;
    max-height: none;
    overflow: visible;
  }
}

.iem-entry-card {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #f9fafb;
  padding: 12px;
}

.iem-entry-card + .iem-entry-card {
  margin-top: 10px;
}

.iem-lab-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
  font-size: 13px;
}

.iem-lab-table th,
.iem-lab-table td {
  border: 1px solid rgba(229, 231, 235, 0.9);
  padding: 8px 8px;
  vertical-align: middle;
}

.iem-lab-table th {
  background: #f8fafc;
  font-weight: 1000;
  color: #111827;
  text-align: left;
  white-space: nowrap;
}

.iem-lab-table .iem-input,
.iem-lab-table .iem-select {
  padding: 7px 8px;
  font-size: 13px;
  border-radius: 8px;
  width: 100%;
  box-sizing: border-box;
}

.iem-lab-table .iem-select {
  height: 34px;
}

.iem-entry-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.iem-entry-meta-row {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: nowrap; /* keep 3 fields in one row */
  background: #f8fafc;
  border: 1px solid rgba(229, 231, 235, 0.9);
  border-radius: 10px;
  padding: 10px 12px;
}

.iem-inline-field {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  min-width: 0;
}

.iem-inline-label {
  font-size: 12px;
  font-weight: 1000;
  color: #111827;
  white-space: nowrap;
}

.iem-inline-field .iem-input {
  width: 140px; /* shorter inputs to fit one row */
  min-width: 0;
}

.iem-entry-title {
  font-size: 13px;
  font-weight: 900;
  color: #111827;
}

/* If we intentionally render an empty title placeholder, hide it */
.iem-entry-title:empty {
  display: none;
}

.iem-small-btn {
  border: 1px solid var(--color-border, #e7ebee);
  background: #fff;
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
  color: #475569;
}

.iem-small-btn:hover {
  border-color: rgba(116, 86, 241, 0.35);
  background: rgba(116, 86, 241, 0.06);
}

.iem-small-btn--danger {
  color: #b91c1c;
  border-color: rgba(239, 68, 68, 0.4);
}

.iem-divider {
  height: 1px;
  background: rgba(229, 231, 235, 0.9);
  margin: 14px 0;
}

.iem-form-actions {
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.iem-status-bar {
  margin: 12px 0 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #eff6ff;
  color: #4f46e5;
  font-size: 13px;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 8px;
}

.iem-status-bar--done {
  background: rgba(34, 197, 94, 0.08);
  color: #15803d;
}

.iem-status-bar--error {
  background: rgba(239, 68, 68, 0.08);
  color: #b91c1c;
}

.iem-result {
  margin-top: 14px;
}

.iem-result-empty {
  border: 1px dashed rgba(229, 231, 235, 0.9);
  background: #f9fafb;
  border-radius: 10px;
  padding: 12px;
  font-size: 13px;
  color: #6b7280;
}

.iem-result-section {
  border: 1px solid rgba(229, 231, 235, 0.9);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
  margin-bottom: 10px;
}

.iem-result-section-head {
  background: #f8fafc;
  border-bottom: 1px solid rgba(229, 231, 235, 0.9);
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 1000;
  color: #111827;
}

.iem-result-section-body {
  padding: 10px 12px 12px;
  color: #334155;
  font-size: 14px;
  line-height: 1.7;
  white-space: pre-wrap;
}

.iem-collapsible {
  margin-top: 12px;
  border: 1px solid rgba(229, 231, 235, 0.9);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
}

.iem-collapsible-head {
  width: 100%;
  border: none;
  background: #f8fafc;
  padding: 10px 12px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.iem-collapsible-body {
  padding: 10px 12px 12px;
  white-space: pre-wrap;
  font-size: 12px;
  color: #334155;
  border-top: 1px solid rgba(229, 231, 235, 0.9);
}

.iem-json-pre {
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 12px;
  white-space: pre-wrap;
}

@media (max-width: 900px) {
  .iem-form-grid {
    grid-template-columns: 1fr;
  }
}

