/* Page scaffolding: header, app grid, sidebar/workspace, panels and their
   titles/collapse behavior, and the header's Start Analysis button. */

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px 20px 0;
}

.site-logo {
  display: block;
  width: min(260px, 100%);
  height: auto;
  margin-bottom: 0px;
  cursor: pointer;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.restart-button {
  width: auto;
  min-height: 48px;
  border: 1px solid var(--restart-strong);
  border-radius: 8px;
  background: var(--restart);
  color: var(--panel);
  padding: 0 14px;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
}

.restart-button:hover {
  background: var(--restart-strong);
}

.restart-button:focus-visible {
  outline: 3px solid var(--focus-restart);
  outline-offset: 2px;
}

.app {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  /* Fill the row to the grid's min-height so the workspace (and its plot +
     table panels) uses the full viewport instead of sizing to content. */
  grid-template-rows: minmax(0, 1fr);
  gap: 20px;
  min-height: calc(100vh - 88px);
  padding: 8px 20px 56px;
}

.sidebar,
.workspace {
  min-width: 0;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.workspace {
  display: flex;
  min-height: 0;
  flex-direction: column;
  gap: 16px;
}

.panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  padding: 16px;
}

.parsed-files-panel {
  display: flex;
  flex: 1;
  /* Modest min so that when both the Plot and table panels are shown they
     share the workspace (flex: 1 each) instead of each demanding most of
     the viewport. A lone panel still fills via flex-grow. */
  min-height: 220px;
  flex-direction: column;
}

.table-wrap {
  flex: 1;
  min-height: 0;
  max-height: calc(100vh - 230px);
  overflow: auto;
}

.metadata-panel-body {
  display: flex;
  flex: 1;
  min-height: 0;
}

.metadata-panel-body[hidden] {
  display: none !important;
}

.parsed-files-panel.is-collapsed {
  flex: 0 0 auto;
  min-height: 0;
  padding-bottom: 12px;
}

.parsed-files-panel.is-collapsed h2 {
  margin-bottom: 0;
}

.panel-title {
  margin-bottom: 14px;
}

.panel-title h2 {
  margin-bottom: 8px;
}

/* Flex column keeps the metadata title text/chevron vertically stable when
   expanding/collapsing. */
.panel-title-toggle {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  width: 100%;
  min-height: 32px;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 0;
  text-align: left;
  cursor: pointer;
}

.metadata-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 32px;
  margin-bottom: 8px;
  font-size: 1rem;
  font-weight: 700;
}

.metadata-title-text {
  line-height: 1.2;
}

.panel-chevron {
  display: inline-block;
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
}

.panel-title-rule {
  display: block;
  width: 100%;
  height: 2px;
  border-radius: 999px;
  background: var(--logo-teal);
}

.parsed-files-panel.is-collapsed .panel-title {
  margin-bottom: 0;
}

.parsed-files-panel.is-collapsed .panel-title-rule {
  display: none;
}

.parsed-files-panel.is-collapsed .metadata-title-row {
  margin-bottom: 0;
}

.table-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 14px;
}

.start-analysis-button {
  width: auto;
  min-width: 150px;
  min-height: 48px;
  border: 1px solid var(--success-strong);
  border-radius: 8px;
  background: var(--success);
  color: var(--panel);
  padding: 0 14px;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
}

.start-analysis-button:hover:not(:disabled) {
  background: var(--success-strong);
}

/* Once analysis has run the button becomes "Start Modeling (DJF)" in blue. */
.start-analysis-button.modeling {
  border-color: var(--accent-strong);
  background: var(--accent);
}

.start-analysis-button.modeling:hover:not(:disabled) {
  background: var(--accent-strong);
}

.start-analysis-button:focus-visible {
  outline: 3px solid var(--focus-success);
  outline-offset: 2px;
}

/* Keep the button's color when disabled, just dimmed (less washed-out). */
.start-analysis-button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
