/* =============================================================================
   OP Billing — enterprise workspace styles
   All OP Billing UI styles live here. Do not use inline styles in views.
   ============================================================================= */

.opb-workspace {
  --opb-accent: #0f766e;
  --opb-accent-soft: #ecfdf5;
  --opb-border: #e2e8f0;
  --opb-muted: #64748b;
  --opb-surface: #ffffff;
  --opb-bg: #f8fafc;
  --opb-radius: 14px;
  --opb-radius-sm: 10px;
  --opb-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  --opb-gap: 16px;
  max-width: 1480px;
  margin: 0 auto;
}

/* Layout ------------------------------------------------------------------- */

.opb-form {
  display: flex;
  flex-direction: column;
  gap: var(--opb-gap);
}

.opb-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: var(--opb-gap);
  align-items: start;
}

.opb-main {
  position: relative;
  z-index: 1;
  min-width: 0;
}

.opb-sidebar {
  position: sticky;
  top: 16px;
  display: flex;
  flex-direction: column;
  gap: var(--opb-gap);
}

.opb-settlement {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.opb-panel--spaced {
  margin-top: var(--opb-gap);
}

@media (max-width: 1100px) {
  .opb-layout {
    grid-template-columns: 1fr;
  }

  .opb-sidebar {
    position: static;
  }
}

/* Toolbar ------------------------------------------------------------------ */

.opb-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 18px;
  background: var(--opb-surface);
  border: 1px solid var(--opb-border);
  border-radius: var(--opb-radius);
  box-shadow: var(--opb-shadow);
}

.opb-toolbar__title {
  font-size: 13px;
  font-weight: 700;
  color: var(--opb-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.opb-toolbar__form,
.opb-toolbar form {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex: 1;
  flex-wrap: wrap;
  margin: 0;
}

.opb-toolbar .eu-field {
  margin: 0;
  min-width: 140px;
}

.opb-toolbar .eu-input {
  height: 40px;
}

.opb-patient-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: var(--opb-accent-soft);
  border: 1px solid #99f6e4;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: #115e59;
  margin-left: auto;
}

.opb-patient-chip span {
  font-weight: 500;
  color: var(--opb-muted);
}

/* Panels ------------------------------------------------------------------- */

.opb-panel {
  background: var(--opb-surface);
  border: 1px solid var(--opb-border);
  border-radius: var(--opb-radius);
  box-shadow: var(--opb-shadow);
  overflow: hidden;
}

.opb-panel--add-service {
  overflow: visible;
  position: relative;
  z-index: 30;
}

.opb-panel--add-service .opb-panel__body {
  overflow: visible;
}

.opb-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--opb-border);
  background: linear-gradient(180deg, #fafbfc 0%, #fff 100%);
}

.opb-panel__title {
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
}

.opb-panel__subtitle {
  font-size: 12px;
  color: var(--opb-muted);
  margin-top: 2px;
}

.opb-panel__body {
  padding: 16px 18px;
}

.opb-panel__body--flush {
  padding: 0;
}

.opb-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--opb-accent);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

/* Add service -------------------------------------------------------------- */

.opb-add-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 88px 120px;
  gap: 10px;
  align-items: end;
}

.opb-add-bar .eu-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--opb-muted);
  margin-bottom: 6px;
  display: block;
}

.opb-add-bar .eu-input,
.opb-add-bar .eu-btn {
  height: 42px;
}

.opb-add-bar .eu-btn {
  width: 100%;
  font-weight: 700;
}

.opb-add-bar .eu-btn.is-loading {
  opacity: 0.7;
  pointer-events: none;
}

/* Autocomplete ------------------------------------------------------------- */

.opb-autocomplete {
  position: relative;
  z-index: 40;
}

.opb-autocomplete__menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 2000;
  background: #fff;
  border: 1px solid var(--opb-border);
  border-radius: var(--opb-radius-sm);
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.18);
  max-height: 260px;
  overflow-y: auto;
}

.opb-autocomplete__item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 11px 14px;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
  font-size: 14px;
}

.opb-autocomplete__item:hover,
.opb-autocomplete__item.is-active {
  background: #eff6ff;
}

.opb-autocomplete__item small {
  color: var(--opb-muted);
  font-weight: 600;
  white-space: nowrap;
}

.opb-autocomplete__empty {
  padding: 14px;
  color: var(--opb-muted);
  font-size: 13px;
}

/* Table -------------------------------------------------------------------- */

.opb-table-wrap {
  overflow-x: auto;
}

.opb-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.opb-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fafc;
  text-align: left;
  padding: 10px 12px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--opb-muted);
  border-bottom: 1px solid var(--opb-border);
  white-space: nowrap;
}

.opb-table td {
  padding: 12px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}

.opb-table tbody tr:hover {
  background: #fafbfc;
}

.opb-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.opb-table .service-name {
  font-weight: 600;
  color: #0f172a;
  max-width: 220px;
}

/* Empty state -------------------------------------------------------------- */

.opb-empty {
  padding: 48px 24px;
  text-align: center;
  color: var(--opb-muted);
}

.opb-empty__icon {
  font-size: 32px;
  margin-bottom: 8px;
  opacity: 0.5;
}

.opb-empty__hint {
  font-size: 12px;
  margin-top: 4px;
}

/* Patient sidebar ---------------------------------------------------------- */

.opb-patient-card {
  display: grid;
  gap: 10px;
}

.opb-patient-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}

.opb-patient-row dt {
  color: var(--opb-muted);
  font-weight: 500;
}

.opb-patient-row dd {
  margin: 0;
  font-weight: 600;
  color: #0f172a;
  text-align: right;
}

/* Bill summary ------------------------------------------------------------- */

.opb-summary-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  font-size: 13px;
  border-bottom: 1px dashed #e2e8f0;
}

.opb-summary-line:last-child {
  border-bottom: 0;
}

.opb-summary-line span:first-child {
  color: var(--opb-muted);
}

.opb-summary-line span:last-child {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.opb-summary-line--total {
  margin-top: 8px;
  padding-top: 14px;
  border-top: 2px solid #0f172a;
  border-bottom: 0;
  font-size: 16px;
}

.opb-summary-line--total span:last-child {
  font-size: 22px;
  font-weight: 800;
  color: var(--opb-accent);
}

/* Remarks ------------------------------------------------------------------ */

.opb-remarks-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.opb-remarks-grid textarea {
  width: 100%;
  min-height: 72px;
  resize: vertical;
}

/* Actions bar (full width) ------------------------------------------------- */

.opb-actions-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 14px 18px;
  background: var(--opb-surface);
  border: 1px solid var(--opb-border);
  border-radius: var(--opb-radius);
  box-shadow: var(--opb-shadow);
}

.opb-actions-bar__buttons {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}

.opb-actions-bar__hint {
  flex: 1;
  font-size: 12px;
  color: var(--opb-muted);
  line-height: 1.5;
  min-width: 200px;
}

.opb-actions-bar__secondary {
  margin-left: auto;
}

.opb-action-btn {
  height: 44px;
  min-width: 140px;
  font-weight: 700;
  border-radius: 12px;
}

.opb-action-btn--primary {
  background: var(--app-primary, #2563eb);
  border-color: var(--app-primary, #2563eb);
  color: #fff;
}

.opb-action-btn--primary:hover {
  background: var(--app-primary-strong, #1d4ed8);
  border-color: var(--app-primary-strong, #1d4ed8);
}

/* Payment strip (full width, horizontal) ----------------------------------- */

.opb-payment-strip {
  background: var(--opb-surface);
  border: 1px solid var(--opb-border);
  border-radius: var(--opb-radius);
  box-shadow: var(--opb-shadow);
  overflow: hidden;
}

.opb-payment-strip[hidden] {
  display: none !important;
}

.opb-payment-strip.is-open {
  border-color: var(--app-primary, #2563eb);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--app-primary, #2563eb) 12%, transparent);
}

.opb-payment-strip__toolbar {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  padding: 14px 18px;
  border-bottom: 1px solid var(--opb-border);
  background: linear-gradient(180deg, #fafbfc 0%, #fff 100%);
}

.opb-payment-strip__intro {
  flex: 1;
  min-width: 220px;
}

.opb-payment-strip__title {
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
}

.opb-payment-strip__subtitle {
  font-size: 12px;
  color: var(--opb-muted);
  margin-top: 2px;
}

.opb-payment-strip__metrics {
  display: flex;
  align-items: stretch;
  gap: 12px;
  flex-wrap: wrap;
}

.opb-metric {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 14px;
  background: var(--opb-bg);
  border: 1px solid var(--opb-border);
  border-radius: var(--opb-radius-sm);
  min-width: 100px;
}

.opb-metric__label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--opb-muted);
}

.opb-metric__value {
  font-size: 16px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: #0f172a;
}

.opb-metric__value--primary {
  color: var(--app-primary, #2563eb);
}

.opb-remaining.is-error {
  color: #dc2626;
}

.opb-payment-strip__tools {
  flex-shrink: 0;
}

/* Payment cards — horizontal left-to-right ----------------------------------- */

.opb-payment-strip__lines {
  display: flex;
  flex-direction: row;
  gap: 14px;
  padding: 16px 18px;
  overflow-x: auto;
  align-items: stretch;
  scroll-snap-type: x proximity;
  background: var(--opb-bg);
}

.opb-payment-card {
  flex: 0 0 260px;
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  background: var(--opb-surface);
  border: 1px solid var(--opb-border);
  border-radius: var(--opb-radius-sm);
  box-shadow: var(--opb-shadow);
}

.opb-payment-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.opb-payment-card__label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--opb-muted);
}

.opb-payment-card__field .eu-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--opb-muted);
  margin-bottom: 4px;
  display: block;
}

.opb-payment-card__field .eu-input,
.opb-payment-card__field .eu-select {
  width: 100%;
  height: 40px;
}

.opb-amount-field {
  display: flex;
  gap: 6px;
}

.opb-amount-field .eu-input {
  flex: 1;
  min-width: 0;
}

.opb-fill-btn {
  flex-shrink: 0;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--opb-border);
  border-radius: 8px;
  background: #fff;
  font-size: 11px;
  font-weight: 700;
  color: var(--app-primary, #2563eb);
  cursor: pointer;
  transition: background 0.15s;
}

.opb-fill-btn:hover {
  background: #eff6ff;
}

.opb-payment-strip__footer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-top: 1px solid var(--opb-border);
  background: #fff;
}

.opb-payment-strip__footer .opb-action-btn {
  min-width: 200px;
}

/* Icon buttons ------------------------------------------------------------- */

.opb-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid #fecaca;
  background: #fff;
  color: #dc2626;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
}

.opb-icon-btn--sm {
  width: 28px;
  height: 28px;
  font-size: 12px;
}

.opb-icon-btn:hover {
  background: #fef2f2;
}

/* Flash -------------------------------------------------------------------- */

.opb-flash {
  margin-bottom: 12px;
}

.opb-flash .eu-alert {
  border-radius: var(--opb-radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
}

.opb-flash .eu-alert-success {
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
  animation: opb-flash-in 0.2s ease;
}

.opb-flash .eu-alert-danger {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

@keyframes opb-flash-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Responsive --------------------------------------------------------------- */

@media (max-width: 700px) {
  .opb-add-bar {
    grid-template-columns: 1fr;
  }

  .opb-remarks-grid {
    grid-template-columns: 1fr;
  }

  .opb-actions-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .opb-actions-bar__buttons {
    flex-direction: column;
  }

  .opb-actions-bar__secondary {
    margin-left: 0;
    text-align: center;
  }

  .opb-action-btn {
    width: 100%;
    min-width: 0;
  }

  .opb-payment-strip__toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .opb-payment-strip__metrics {
    width: 100%;
  }

  .opb-metric {
    flex: 1;
    min-width: 0;
  }

  .opb-payment-card {
    flex-basis: 240px;
  }
}
