/* om_historical_html - the Historical Owings panel.
 *
 * Kept here because the Anvil server strips a <style> block out of an HTML
 * template. Rules are scoped by their selector preludes.
 *
 * SCOPE. .oh-container is the form root, so its own rule stays a bare class and
 * every other rule is scoped :where(.oh-container), which adds zero specificity
 * and so cannot change which rule wins. The root keeps exactly the six
 * declarations and five custom properties it shipped with: no height, no
 * overflow-y, no .px-screen-root. It is an embedded panel, not a screen.
 *
 * HEAD-LINK ORDER, and the rules that need a real ancestor. This asset is a
 * head <link>, so it loads BEFORE theme/assets/theme.css ties are decided by
 * document order and before the dependency's runtime theme injection.
 * .oh-table carries both oh-table and px-table, so every .oh-table thead / th /
 * td / tbody rule ties a .px-table twin at the same specificity. Those are
 * written with .oh-container as a REAL ancestor rather than :where(), one class
 * heavier than the theme's, which is how they win. The two @media
 * .px-page-title copies tie theme.css's .px-page-title the same way (a media
 * query adds no specificity) and are promoted for the same reason. The @media
 * (max-width: 768px) copy of .oh-table tbody tr:hover is promoted too: it has to
 * stay at least as specific as the base rule it overrides, or the narrow-screen
 * `transform: none` would lose to it.
 *
 * .oh-table tbody tr:hover is promoted to (0,3,1) and no further:
 * theme/assets/theme.css's [data-theme="dark"] .px-table tbody tr:hover is
 * (0,3,1) and already beats this rule in dark mode today, so the tie keeps the
 * theme there, which is today's rendering.
 *
 * THE .px-modal RULE IS NOT SCOPED ON THE ROOT. As a body <style> it reached
 * every .px-modal in the document, and the one that matters is the
 * px_form_alert modal that CONTAINS this panel - an ancestor, so
 * :where(.oh-container) .px-modal would make it dead and a bare .px-modal in a
 * head asset would make the leak permanent and app-wide. :has() reproduces
 * today's effect exactly and its (0,2,0) beats the dependency's .px-modal at
 * (0,1,0).
 *
 * KEYFRAMES ARE NOT RENAMED. pxFadeIn and pxRowReveal are defined app-wide in
 * theme/assets/theme.css and only referenced here; they are not this
 * form's to prefix.
 *
 * DESIGNER GATE: none, deliberately. Nothing here is hidden until JavaScript
 * runs. #oh-loading-overlay ships with the `active` class in the markup and the
 * dependency's .px-loading-overlay rule is what shows it, so the canvas shows
 * what the browser shows on first paint.
 */

.oh-container {
  --accent: #ea580c;
  --accent-hover: #c2410c;
  --accent-subtle: rgba(234, 88, 12, 0.12);
  --oh-row-hover: rgba(234, 88, 12, 0.06);
  --oh-home-bg: linear-gradient(135deg, #ea580c 0%, #c2410c 100%);
  --px-loading-accent: #ea580c;
  font-family: var(--px-font);
  color: var(--px-text-primary);
  background: var(--px-bg-deep);
  position: relative;
  isolation: isolate;
  z-index: 0;
}

/* [data-theme] sits on <html>, an ancestor of the root, so this selector stays
   outside any scope. */
[data-theme="dark"] .oh-container {
  --accent: #f97316;
  --accent-hover: #ea580c;
  --accent-subtle: rgba(249, 115, 22, 0.25);
  --oh-row-hover: rgba(249, 115, 22, 0.15);
  --oh-home-bg: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
}

:where(.oh-container) .oh-content {
  padding: 24px 32px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  animation: pxFadeIn 0.4s ease;
}

:where(.oh-container) .oh-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

/* ===== Filters Card ===== */
:where(.oh-container) .oh-filters-card {
  background: var(--px-bg-card);
  border: 1px solid var(--px-border);
  border-radius: 12px;
  box-shadow: var(--px-shadow), var(--px-shadow-md);
  padding: 20px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

:where(.oh-container) .oh-input {
  font-family: var(--px-font);
  font-size: 13px;
  padding: 10px 14px;
  border: 1px solid var(--px-border);
  border-radius: 8px;
  background: var(--px-input-bg);
  color: var(--px-text-primary);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  width: 100%;
}

:where(.oh-container) .oh-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

:where(.oh-container) .oh-input::placeholder {
  color: var(--px-text-muted);
}

/* ===== Table Card ===== */
:where(.oh-container) .oh-table-card {
  background: var(--px-bg-card);
  border: 1px solid var(--px-border);
  border-radius: 12px;
  box-shadow: var(--px-shadow), var(--px-shadow-md);
  overflow: hidden;
}

:where(.oh-container) .oh-table-scroll {
  max-height: 65vh;
  overflow-y: auto;
}

.oh-container .oh-table thead {
  background: var(--oh-home-bg);
}

.oh-container .oh-table th {
  font-family: var(--px-mono);
  font-size: 0.8rem;
  font-weight: 700;
}

.oh-container .oh-table td {
  font-size: 13px;
  color: var(--px-text-secondary);
}

.oh-container .oh-table tbody tr:hover {
  background-color: var(--oh-row-hover);
  transform: translateX(4px);
}

/* Row reveal stagger animation */
.oh-container .oh-table tbody tr {
  animation: pxRowReveal 0.3s ease both;
}

:where(.oh-container) .oh-status-completed {
  border-left: 3px solid #10b981;
}

:where(.oh-container) .oh-status-cancelled {
  border-left: 3px solid #ef4444;
}

:where(.oh-container) .oh-status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

:where(.oh-container) .oh-status-badge-completed {
  background: rgba(16, 185, 129, 0.12);
  color: #10b981;
}

:where(.oh-container) .oh-status-badge-cancelled {
  background: rgba(239, 68, 68, 0.12);
  color: #ef4444;
}

:where(.oh-container) .oh-no-results {
  text-align: center;
  padding: 48px 24px;
  color: var(--px-text-muted);
  font-size: 15px;
  font-family: var(--px-mono);
}

/* ===== Responsive ===== */
@media (max-width: 900px) {
  :where(.oh-container) .oh-content { padding: 16px; gap: 16px; }
  .oh-container .px-page-title { font-size: 1.5rem; }
  :where(.oh-container) .oh-filters-card { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
}

@media (max-width: 768px) {
  :where(.oh-container) .oh-table-card {
    background: transparent;
    border: none;
    box-shadow: none;
    border-radius: 0;
    overflow: visible;
  }
  :where(.oh-container) .oh-table-scroll {
    max-height: none;
    overflow-y: visible;
  }
  .oh-container .oh-table tbody tr:hover {
    transform: none;
  }
}

@media (max-width: 600px) {
  :where(.oh-container) .oh-content { padding: 12px; gap: 12px; }
  .oh-container .px-page-title { font-size: 1.25rem; }
  :where(.oh-container) .oh-filters-card { grid-template-columns: 1fr; }
  .px-modal:has(.oh-container) { border-radius: 0; max-height: 100vh; }
}
