/* Consolidated styles for the usage-and-statistics site */

/* ===== Layout / Base ===== */
:root {
  --card-padding: 24px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #f4f6f8;
  color: #111;
  font-family: 'Inter Variable', Inter, system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  font-weight: 300;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.03em;
}

.container {
  margin: 0 28px;
}

h1 {
  font-size: 2rem;
  font-weight: 150;
  display: inline-block;
  margin: 10px 0;
}

.muted {
  color: #9296aa;
  font-size: 0.95rem;
}

.sup {
  font-size: 0.6em;
  font-weight: 300;
}

/* ===== Cards ===== */
.card {
  border-radius: 0 0 8px 8px;
  padding: 28px 16px 16px;
  margin-bottom: 16px;
  background: #fff;
  border-left: 2px solid #444a65;
  border-right: 2px solid #444a65;
  border-bottom: 2px solid #444a65;
  min-width: 600px;
  position: relative;
}

.tabbed-card {
  padding: 10px 10px 24px;
  width: 100%;
}

/* ===== Resizable tab content + handle ===== */
.resizable-tab-content {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  position: relative;
  resize: horizontal;
  overflow: auto;
  width: min(1200px, calc(100vw - 56px));
  min-width: 320px;
  max-width: 100%;
  padding-right: 18px;
}

.resizable-tab-content .tabbed-card,
.resizable-tab-content .tab-content {
  width: 100%;
}

.resize-handle {
  position: absolute;
  top: 50px;
  right: 2px;
  width: 16px;
  height: fit-content;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: ew-resize;
  z-index: 10;
  background: linear-gradient(to left, rgba(220, 220, 220, 0.7) 5%, transparent 100%);
  border-radius: 0 8px 8px 0;
  user-select: none;
  transition: background 0.18s;
}

.resize-handle:hover svg rect {
  fill: #888;
}

/* ===== Tab UI ===== */
.tab-bar {
  display: flex;
  gap: 0;
  width: 100%;
  border-top-left-radius: 10px;
  border-top-right-radius: 10px;
  border-bottom: 2px solid #444a65;
  position: relative;
  z-index: 2;
}

.tab-bar.dark {
  border-bottom: 2px solid #444a65;
}

.tab-btn {
  appearance: none;
  border: none;
  background: linear-gradient(180deg, #555a7a 80%, #444a65 100%);
  color: #fff;
  font-weight: 600;
  font-size: 1.05rem;
  padding: 12px 32px 10px;
  border-right: 1px solid #35374a;
  border-top-left-radius: 10px;
  border-top-right-radius: 10px;
  cursor: pointer;
  margin-bottom: -2px;
  transition: background 0.18s, color 0.18s;
}

.tab-btn:last-child {
  border-right: none;
}

.tab-btn.active {
  background: #fff;
  color: #222;
  border-bottom: 2px solid #fff;
  border-left: 2px solid #444a65;
  border-right: 2px solid #444a65;
  border-top: 2px solid #444a65;
  box-shadow: 0 4px 12px rgba(68, 74, 101, 0.1);
  z-index: 3;
}

.tab-btn:not(.active):hover {
  background: #5a5e7e;
  color: #fff;
}

.tab-content {
  background: #fff;
  border-bottom-left-radius: 10px;
  border-bottom-right-radius: 10px;
  padding: 0 32px 32px;
  position: relative;
  z-index: 10;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.tab-panel-header {
  margin-bottom: 1em;
  margin-top: 10px;
}

.tab-panel-header h3 {
  margin: 0 0 0.2em;
  font-size: 1.1rem;
  font-weight: 600;
}

.tdHead {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
}

.downloaded-bold {
  font-weight: 400;
}

.size-unit {
  margin-left: 4px;
  font-weight: 700;
}

.lookerFrame {
  width: 100%;
  height: 450px;
}

/* Dataportal wide tab helpers */
.tabbed-card-outer.wide-tab .tabbed-card {
  border-radius: 0;
  box-shadow: none;
}

.tabbed-card-outer.wide-tab .tab-panel-header {
  margin-left: calc(-1 * var(--card-padding));
  margin-right: calc(-1 * var(--card-padding));
  width: calc(100% + 2 * var(--card-padding));
  padding: 0;
}

.tabbed-card-outer.wide-tab iframe.lookerFrame {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  height: 80vh;
  display: block;
  border: none;
}

#organsTable .organ-side {
  font-style: italic;
  font-size: 0.85em;
  font-weight: 350;
  color: #888;
}

/* ===== Tables ===== */
.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: #fff;
  border: 1px solid #e0e3ef;
  box-shadow: 0 1px 4px rgba(68, 74, 101, 0.04);
  font-size: 0.98rem;
  margin: 10px 0 18px;
  border-radius: 8px;
  overflow: hidden;
}

.data-table th,
.data-table td {
  padding: 8px 16px;
  text-align: left;
}

.data-table th {
  background: #f6f7fa;
  color: #222;
  font-weight: 600;
  border-bottom: 2px solid #e0e3ef;
}

.data-table tbody tr:nth-child(even) {
  background-color: rgba(68, 74, 101, 0.1);
}

.data-table tbody tr:nth-child(odd) {
  background-color: #fff;
}

.data-table tbody tr:hover {
  background-color: rgba(68, 74, 101, 0.04);
}

.data-table td {
  border-bottom: 1px solid #ececf2;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table td:not(:last-child) {
  border-right: 2px solid #e0e3ef;
}

#downloadedDataTable,
#datasetsTable,
#organsTable {
  border: 2px solid #444a65 !important;
}

#downloadedDataTable.data-table th,
#datasetsTable.data-table th,
#organsTable.data-table th {
  background: #cfd3e2 !important;
}

#downloadedDataTable tr td,
#datasetsTable tr td,
#organsTable tr td {
  border-bottom: 1px solid #444a65 !important;
  border-left: 1px solid #444a65 !important;
}

#downloadedDataTable tr td.accumulatedTotal {
  font-variant-numeric: tabular-nums;
  text-align: right;
  font-size: 1rem !important;
  font-weight: 500 !important;
  line-height: 1.66;
}

#downloadedDataTable tr td.numFormat {
  font-variant-numeric: tabular-nums;
  text-align: right;
  font-size: 1rem !important;
  font-weight: 500 !important;
}

#downloadedDataTable tr td.numFormat span.sup,
#downloadedDataTable tr td.accumulatedTotal span.sup {
  margin-left: 4px;
  font-variant-position: sub;
  font-size: 0.75rem;
}

#downloadedDataTable.data-table tr td:nth-child(even),
#datasetsTable.data-table tr td:nth-child(even),
#organsTable.data-table tr td:nth-child(even) {
  font-weight: 400;
  font-size: 0.75rem;
  letter-spacing: 0.03333em;
}

#downloadedDataTable tbody tr:first-child {
  background: #444a65 !important;
  color: #fff !important;
  font-weight: 700;
  border-bottom: 5px solid #444a65 !important;
}

#downloadedDataTable thead th.downloaded-header {
  text-align: right;
}

/* ===== Buttons ===== */
.btn {
  background: transparent;
  border: 1px solid rgba(2, 6, 23, 0.08);
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
}

.btn.primary {
  background: #0753ff;
  color: #fff;
  border: none;
}

.btn:focus {
  outline: 2px solid rgba(7, 83, 255, 0.16);
}

/* ===== Loading overlays ===== */
.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  pointer-events: auto;
}

.loading-overlay .spinner-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 6px;
  border-radius: 8px;
}

.loading-overlay .spinner {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 6px solid rgba(68, 74, 101, 0.12);
  border-top-color: #444a65;
  animation: loading-spin 1s linear infinite;
}

.loading-overlay .loading-text {
  font-size: 0.95rem;
  color: #222;
  font-weight: 600;
}

@keyframes loading-spin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

#dataportal-tab {
  position: relative;
}

#dataportal-tab .iframe-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  background: rgba(255, 255, 255, 0.86);
}

/* ===== Error / modal overlay ===== */
.error-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.36);
  padding: 20px;
}

.error-card {
  background: #fff;
  border-radius: 12px;
  max-width: 820px;
  width: 100%;
  padding: 22px 20px;
  box-shadow: 0 10px 30px rgba(2, 6, 23, 0.18);
}

.error-card h2 {
  margin: 0 0 6px;
  color: #c53030;
}

.error-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 14px;
}

.error-badge {
  background: #f3f4f6;
  color: #111;
  padding: 6px 8px;
  border-radius: 999px;
  font-size: 0.8rem;
  border: 1px solid rgba(2, 6, 23, 0.06);
}

.error-badge.timeout {
  background: #fff7ed;
  color: #92400e;
  border: 1px solid #ffd8a8;
}

.error-badge.network {
  background: #fff1f2;
  color: #9f1239;
  border: 1px solid #fecaca;
}

/* ===== Shell/Layout helpers for portal mode ===== */
.shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.sidebar {
  width: 100%;
  box-shadow: rgba(0, 0, 0, 0.12) 0 6px 18px;
  color: #fff;
  height: 56px;
  background-color: #444a65;
  display: flex;
  align-items: center;
  gap: 16px;
  justify-content: space-between;
  padding: 0 12px;
  z-index: 50;
}

.sidebar .brand #hubmapLogo {
  height: 30px;
}

.sidebar .lastTouch {
  font-size: 0.8em;
  display: flex;
  flex-direction: column;
}

.frame-area {
  flex: 1;
  padding: 0;
  background: #f4f6f8;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.frame-area iframe {
  width: 100%;
  flex: 1 1 auto;
  height: 100%;
  border: 0;
  border-radius: 10px;
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.grid.single-column {
  grid-template-columns: 1fr;
}

.card-portal {
  padding: 0;
  height: calc(100vh - 84px);
  min-height: 480px;
  display: flex;
  flex-direction: column;
}

.card-portal iframe {
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  border: 0;
  padding: 10px;
}

.site-footer {
  margin-top: 18px;
  text-align: center;
  font-size: 0.9rem;
}

/* ===== Responsive ===== */
@media (max-width: 900px) {
  .resizable-tab-content {
    min-width: 200px;
  }
}

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