/* Pamba Admin component layer
 * Reusable shell, navigation, modal and data-display primitives. Keep page-
 * specific styling in the template while new work adopts these components.
 */
:root {
  --ops-radius-sm: 9px;
  --ops-radius-md: 13px;
  --ops-radius-lg: 18px;
  --ops-control-height: 42px;
  --ops-focus: #5ee0b0;
  --ops-surface: rgba(15, 28, 24, .92);
  --ops-surface-raised: rgba(19, 36, 31, .96);
  --ops-divider: rgba(148, 163, 184, .14);
}

/* Header actions ---------------------------------------------------------- */
.ops-header-action {
  min-height: var(--ops-control-height);
  border-color: rgba(148, 163, 184, .17) !important;
  background: rgba(255, 255, 255, .035) !important;
}

.ops-header-action:hover {
  border-color: rgba(52, 211, 153, .42) !important;
  background: rgba(52, 211, 153, .09) !important;
}

.ops-header-action--storefront { color: #5ee0b0 !important; }
.ops-header-action--payments { color: #7dd3fc !important; }

.ops-profile-button {
  min-height: var(--ops-control-height);
  border: 1px solid var(--ops-divider);
  appearance: none;
  text-align: left;
}

/* Navigation -------------------------------------------------------------- */
.ops-nav-item--urgent { border-left: 3px solid #ef4444 !important; }
.ops-nav-item--warning { border-left: 3px solid #f59e0b !important; }
.ops-nav-item--success { border-left: 3px solid #10b981 !important; }

.ops-nav-badge {
  display: none;
  min-width: 20px;
  margin-left: auto;
  padding: 2px 7px;
  border-radius: 999px;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  line-height: 1.4;
  text-align: center;
}

.ops-nav-badge--warning { background: #f59e0b; color: #172033; }
.ops-nav-badge--success { background: #10b981; }
.ops-nav-badge--danger { background: #ef4444; }

/* Workspace components --------------------------------------------------- */
.ops-page-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  margin-bottom: 14px;
}

.ops-page-actions .btn { min-height: 40px; }

.section-card,
.kpi-card,
.table-container,
.data-table-wrapper {
  content-visibility: auto;
  contain-intrinsic-size: 1px 420px;
}

.section-header {
  gap: 16px;
  flex-wrap: wrap;
}

.section-header > :first-child { min-width: min(100%, 260px); }

.table-toolbar {
  position: sticky;
  z-index: 5;
  top: var(--shell-header-height, 74px);
  border: 1px solid var(--ops-divider);
  border-radius: var(--ops-radius-md);
  background: rgba(8, 20, 17, .94);
  box-shadow: 0 8px 25px rgba(0, 0, 0, .18);
  backdrop-filter: blur(14px);
}

.admin-inline-state {
  padding: 34px 18px !important;
  color: var(--text-muted) !important;
  text-align: center !important;
}

/* Modal components -------------------------------------------------------- */
/* Visibility is owned by openModal/closeModal. ARIA must describe that state,
   not change it, otherwise closing a dialog creates a CSS feedback loop. */
body.ops-modal-open { overflow: hidden; }

.modal-card {
  width: min(calc(100vw - 28px), 680px);
  max-height: min(90vh, 880px);
  border-color: var(--ops-divider) !important;
  border-radius: var(--ops-radius-lg) !important;
  background: var(--ops-surface-raised) !important;
  box-shadow: 0 28px 80px rgba(0, 0, 0, .55) !important;
  overscroll-behavior: contain;
}

.ops-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
  padding-bottom: 13px;
  border-bottom: 1px solid var(--ops-divider);
}

.ops-modal-close {
  display: inline-grid;
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
}

.ops-modal-close:hover {
  border-color: var(--ops-divider);
  background: rgba(255, 255, 255, .05);
  color: var(--text-main);
}

.modal-actions {
  position: sticky;
  bottom: -1px;
  z-index: 2;
  margin: 18px -2px -2px;
  padding-top: 14px;
  border-top: 1px solid var(--ops-divider);
  background: linear-gradient(180deg, rgba(19, 36, 31, .78), var(--ops-surface-raised) 28%);
}

/* Accessibility and responsive behavior --------------------------------- */
[aria-busy="true"] { cursor: progress; }
[aria-busy="true"] > * { pointer-events: none; }

.tab-btn[aria-selected="true"] { color: #ecfdf5; }

@media (max-width: 1100px) {
  header { padding-inline: 18px; }
  .nav-actions { gap: 8px; }
  .nav-actions .badge-status,
  .ops-header-action span { display: none; }
}

@media (max-width: 760px) {
  :root { --ops-control-height: 44px; }
  .workspace-intro { align-items: flex-start; }
  .workspace-title { font-size: clamp(20px, 7vw, 28px); }
  .table-toolbar { position: static; }
  .modal-overlay { align-items: flex-end !important; padding: 0 !important; }
  .modal-card {
    width: 100%;
    max-width: none !important;
    max-height: 92dvh;
    margin: 0;
    border-radius: 22px 22px 0 0 !important;
  }
  .modal-actions { padding-bottom: max(10px, env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

@media (forced-colors: active) {
  .btn,
  .tab-btn,
  .section-card,
  .kpi-card,
  .modal-card { border: 1px solid CanvasText !important; }
}
#tab-payouts [hidden] { display: none !important; }

[hidden] { display: none !important; }
.admin-workspace-error { margin-bottom: 16px; }

/* A consistent reading rhythm across operational workspaces. */
body .workspace-intro { gap: 16px; padding-bottom: 18px; }
body .workspace-intro > :first-child { min-width: 0; }
body .workspace-title { line-height: 1.2; text-wrap: balance; }
body .workspace-subtitle { max-width: 68ch; margin-bottom: 0; }
body .section-title { line-height: 1.4; }
body .btn { min-height: 40px; line-height: 1.4; }
body .form-control { min-height: 42px; line-height: 1.4; }
body textarea.form-control { min-height: 90px; }
body .kpi-value,
body .metric-value,
body td { font-variant-numeric: tabular-nums; }
body .kpi-value,
body .metric-value { overflow-wrap: anywhere; line-height: 1.2; }
body .table-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
body .table-toolbar > * { min-width: 0; max-width: 100%; }
body tbody tr:last-child td { border-bottom: 0; }
body .data-table-wrapper,
body .table-container { overscroll-behavior-x: contain; }
body .modal-card { scrollbar-gutter: stable; }
body .form-group > label { line-height: 1.5; }

@media (max-width: 760px) {
  body .workspace-intro { flex-wrap: wrap; }
  body .section-header { align-items: flex-start; gap: 12px; }
  body .section-header > :first-child { min-width: 0; flex: 1 1 100%; }
  body .section-header > :last-child { max-width: 100%; flex-wrap: wrap; }
  body .table-toolbar > .form-control,
  body .table-toolbar > .search-box { flex: 1 1 100%; width: 100% !important; }
  body .section-card input.form-control,
  body .section-card select.form-control,
  body .modal-card input.form-control,
  body .modal-card select.form-control,
  body .modal-card textarea.form-control { font-size: 16px; }
  body .modal-card form > [style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: minmax(0, 1fr) !important;
  }
  body .modal-card .form-control { width: 100%; max-width: 100%; min-width: 0; }
}
