/**
 * fdhpy-webtool specific layout, built on top of css/common.css tokens
 */

body {
  padding: 20px;
}

.page {
  max-width: 1520px;
  margin: 0 auto;
}

.app-card {
  margin-bottom: 20px;
}

/* --- Header --- */

.app-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 16px;
}

.app-header-text {
  flex: 1 1 320px; /* wraps to its own line below this */
}

.header-banner {
  height: 56px;
  width: auto;
  max-width: 100%;
  margin-left: auto;
  flex-shrink: 0;
}

/* --- Form controls --- */

.field-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1 1 160px;
}

.field label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text-secondary);
}

.field select,
.field input[type="number"] {
  font-family: inherit;
  font-size: 0.95rem;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--color-border);
  background: var(--color-bg-secondary);
  color: var(--color-text-primary);
}

.field select:focus,
.field input[type="number"]:focus {
  outline: none;
  border-color: var(--color-primary);
}

.calculate-row {
  margin-top: 16px;
}

/* --- Status / loading --- */

.status-line {
  margin-top: 14px;
  font-size: 0.85rem;
  color: var(--color-text-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-text-tertiary);
  flex-shrink: 0;
}

.status-line.is-ready .status-dot {
  background: #16a34a;
}

.status-line.is-working .status-dot {
  background: #d97706;
}

.status-line.is-error .status-dot {
  background: #dc2626;
}

/* --- Error / warning panel --- */

.error-panel {
  margin-top: 16px;
  padding: 12px 16px;
  border-radius: 10px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  font-size: 0.88rem;
  line-height: 1.5;
  display: none;
  white-space: pre-wrap;
}

.error-panel.is-visible {
  display: block;
}

.error-panel .error-title {
  font-weight: 700;
  margin-bottom: 4px;
}

.error-panel.is-warning {
  background: #fffbeb;
  border-color: #fde68a;
  color: #92400e;
}

/* --- Tabs --- */

.tab-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.tab-button {
  background: var(--color-chip-bg);
  color: var(--color-text-secondary);
  box-shadow: none;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 9px 16px;
}

.tab-button:hover {
  background: var(--color-chip-bg);
  color: var(--color-text-secondary);
  opacity: 0.85;
}

.tab-button.is-active {
  background: var(--color-chip-drawn-bg);
  color: var(--color-chip-drawn-text);
  box-shadow: none;
}

.tab-panel {
  display: none;
}

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

/* --- Plot area --- */

.plot-row {
  display: flex;
  gap: 20px;
  margin-top: 16px;
}

.plot-column {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.plot-column-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text-secondary);
}

.plot-area {
  border: 1px solid var(--color-border);
  border-radius: 12px;
  background: var(--color-bg-secondary);
  min-height: 340px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.plot-area img {
  max-width: 100%;
  height: auto;
  display: block;
}

.plot-placeholder {
  color: var(--color-text-tertiary);
  font-size: 0.85rem;
}

/* --- Summary table --- */

.summary-table-container {
  border: 1px solid var(--color-border);
  border-radius: 12px;
  background: var(--color-bg-secondary);
  padding: 14px 16px;
  overflow-x: auto;
}

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

.summary-table-container th,
.summary-table-container td {
  padding: 6px 10px;
  text-align: right;
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}

.summary-table-container th:first-child,
.summary-table-container td:first-child {
  text-align: left;
}

.summary-table-container th {
  font-weight: 700;
  color: var(--color-text-primary);
}

.summary-table-container tbody tr:last-child th,
.summary-table-container tbody tr:last-child td {
  border-bottom: none;
}

.summary-table-container td.is-mean-row {
  font-weight: 700;
}

/* --- Downloads --- */

.download-column {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
}

.download-column button {
  width: 100%;
}
