/* Standalone Bighorn dashboard + iframe sidebars. Self-contained: no ResearchLibrary app-shell styles. */

/* Light theme: warm sand page, cream cards, earthy greens and olive-brown text. */
:root {
  --bh-text: #2f3a2e;
  --bh-muted: #6b6a55;
  --bh-border: #d8cfb8;
  --bh-surface: #fbf8f0;
  --bh-page: #efe8d6;
  --bh-accent: #3f6b4a;
  --bh-ok: #3f6b4a;
  --bh-danger: #a4442e;
  --bh-shadow: 0 1px 2px rgba(60, 50, 30, 0.10), 0 3px 8px rgba(60, 50, 30, 0.08);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bh-text: #e6eaee;
    --bh-muted: #9aa6b2;
    --bh-border: #3a434c;
    --bh-surface: #1b2026;
    --bh-page: #12161a;
    --bh-accent: #7fb3ea;
    --bh-ok: #6fcf73;
    --bh-danger: #ff8a80;
    --bh-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
  }
}

:root[data-theme="dark"] {
  --bh-text: #e6eaee;
  --bh-muted: #9aa6b2;
  --bh-border: #3a434c;
  --bh-surface: #1b2026;
  --bh-page: #12161a;
  --bh-accent: #7fb3ea;
  --bh-ok: #6fcf73;
  --bh-danger: #ff8a80;
  --bh-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 16px;
  background: var(--bh-page);
  color: var(--bh-text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.4;
}

h1,
h2,
h3 {
  margin: 0;
  font-weight: 600;
}

h1 {
  font-size: 1.6rem;
}

h2 {
  font-size: 1.15rem;
  margin-bottom: 10px;
}

h3 {
  font-size: 0.95rem;
  margin-bottom: 6px;
}

a {
  color: var(--bh-accent);
}

/* --- Header --- */

.bh-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
  margin-bottom: 16px;
}

.bh-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.bh-controls select {
  font: inherit;
  padding: 6px 10px;
  border: 1px solid var(--bh-border);
  border-radius: 6px;
  background: var(--bh-surface);
  color: var(--bh-text);
  min-height: 44px; /* touch target */
}

.bh-status {
  width: 100%;
  margin: 0;
  color: var(--bh-muted);
  font-size: 0.85rem;
}

/* --- Sections --- */

.bh-section {
  margin-bottom: 24px;
}

/* --- Daily tables --- */

.bh-tables {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.bh-table-card {
  background: var(--bh-surface);
  border: 1px solid var(--bh-border);
  border-radius: 8px;
  box-shadow: var(--bh-shadow);
  padding: 10px;
  min-width: 0;
}

.bh-table-scroll {
  max-height: 260px;
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

th,
td {
  padding: 4px 8px;
  border-bottom: 1px solid var(--bh-border);
  text-align: left;
  white-space: nowrap;
}

td + td,
th + th {
  text-align: right;
}

td + td {
  font-variant-numeric: tabular-nums;
}

thead th {
  position: sticky;
  top: 0;
  background: var(--bh-surface);
  z-index: 1;
}

.text-success {
  color: var(--bh-ok);
}

.text-danger {
  color: var(--bh-danger);
  font-weight: 600;
}

/* --- Charts --- */

.bh-charts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 460px), 1fr));
  gap: 16px;
}

.bh-chart {
  background: var(--bh-surface);
  border: 1px solid var(--bh-border);
  border-radius: 8px;
  box-shadow: var(--bh-shadow);
  padding: 12px;
  height: 380px;
  min-width: 0;
}

.bh-chart canvas {
  width: 100% !important;
  height: 100% !important;
}

.bh-teacup {
  font-size: 0.9rem;
}

/* --- Iframe sidebars (/vsidebar, /hsidebar) --- */

.bh-sidebar {
  padding: 8px;
  background: transparent;
}

.bh-conditions {
  background: var(--bh-surface);
  border: 1px solid var(--bh-border);
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 12px;
}

.bh-conditions h2 {
  text-align: center;
}

.bh-conditions table {
  font-size: 0.9rem;
}

.bh-value {
  font-weight: 700;
}

.bh-sidebar-chart {
  background: var(--bh-surface);
  border: 1px solid var(--bh-border);
  border-radius: 8px;
  box-shadow: var(--bh-shadow);
  padding: 8px;
  height: 300px;
  min-width: 0;
}

.bh-sidebar-chart canvas {
  width: 100% !important;
  height: 100% !important;
}

.bh-sidebar-chart + .bh-sidebar-chart {
  margin-top: 12px;
}

.bh-sidebar--vertical .bh-conditions,
.bh-sidebar--vertical .bh-sidebar-charts {
  width: 100%;
  max-width: 420px;
}

.bh-sidebar--horizontal .bh-sidebar-charts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.bh-sidebar--horizontal .bh-sidebar-chart + .bh-sidebar-chart {
  margin-top: 0;
}

@media (max-width: 640px) {
  .bh-sidebar--horizontal .bh-sidebar-charts {
    grid-template-columns: 1fr;
  }

  .bh-sidebar--horizontal .bh-sidebar-chart + .bh-sidebar-chart {
    margin-top: 12px;
  }
}
