/* ============================================================
   W-Glass · EN 16612:2019
   Stylesheet — Material-UI inspired, matching old W-Glass look
   ============================================================ */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  color: #333;
  background: #e0e0e0;
  min-height: 100vh;
}

/* ---------- TOP BAR ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #1565C0;
  color: #fff;
  padding: 0 16px;
  height: 48px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.topbar-title { font-size: 16px; font-weight: 500; }

.icon-btn {
  background: transparent;
  border: none;
  color: #fff;
  cursor: pointer;
  font-size: 18px;
  padding: 6px 10px;
  border-radius: 4px;
}
.icon-btn:hover { background: rgba(255,255,255,0.15); }

.login-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
}
.login-icon { font-size: 16px; }

.lang-select {
  background: transparent;
  color: #fff;
  border: 1px solid rgba(255,255,255,0.5);
  border-radius: 4px;
  padding: 4px 6px;
  font-size: 12px;
  cursor: pointer;
}
.lang-select option { color: #333; }

/* ---------- MAIN LAYOUT ---------- */
.main-layout {
  display: grid;
  grid-template-columns: minmax(420px, 620px) 1fr;
  gap: 16px;
  padding: 16px;
  align-items: start;
}
@media (max-width: 900px) {
  .main-layout { grid-template-columns: 1fr; }
}

/* ---------- CARD ---------- */
.card {
  background: #fff;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  overflow: hidden;
}

/* ---------- TABS ---------- */
.tabs {
  display: flex;
  border-bottom: 1px solid #e0e0e0;
  background: #fff;
}
.tab {
  flex: 1;
  padding: 10px 4px 8px;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  font-weight: 600;
  color: #555;
  transition: color 0.2s, border-color 0.2s;
  white-space: nowrap;
}
.tab:hover { color: #1565C0; }
.tab.active {
  color: #222;
  border-bottom-color: #E53935;
}
.tab-icon {
  font-size: 20px;
  line-height: 1;
}

/* ---------- TAB PANELS ---------- */
.tab-panel {
  display: none;
  padding: 20px;
}
.tab-panel.active { display: block; }

.tab-panel h2 {
  margin: 0 0 16px;
  font-size: 18px;
  font-weight: 500;
  color: #222;
}
.tab-panel h3 {
  font-size: 15px;
  font-weight: 600;
  margin: 18px 0 10px;
  color: #222;
}
.tab-panel h4 {
  font-size: 13px;
  font-weight: 600;
  margin: 14px 0 8px;
  color: #444;
}

.tab-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid #eee;
}

/* ---------- FORM FIELDS (MUI look) ---------- */
.form-row {
  display: flex;
  gap: 14px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.field {
  position: relative;
  flex: 1 1 160px;
  min-width: 140px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.field-full { flex: 1 1 100%; }
.field-label {
  font-size: 11px;
  color: #1565C0;
  font-weight: 500;
  text-transform: none;
}
.field input,
.field select {
  padding: 8px 10px;
  border: 1px solid #bbb;
  border-radius: 4px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  transition: border-color 0.2s;
  width: 100%;
}
.field input:focus,
.field select:focus {
  outline: none;
  border-color: #1565C0;
  box-shadow: 0 0 0 2px rgba(21, 101, 192, 0.15);
}
.field .unit {
  position: absolute;
  right: 10px;
  bottom: 9px;
  font-size: 12px;
  color: #888;
  pointer-events: none;
}

/* ---------- BUTTONS ---------- */
.btn-primary {
  background: #fff;
  color: #1565C0;
  border: 1px solid #1565C0;
  border-radius: 4px;
  padding: 8px 22px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.btn-primary:hover {
  background: #1565C0;
  color: #fff;
}
.solve-btn { min-width: 120px; }

.btn-add {
  background: #26A69A;
  color: #fff;
  border: none;
  border-radius: 4px;
  width: 28px;
  height: 28px;
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
}
.btn-add:hover { background: #00897B; }

.btn-del {
  background: #E53935;
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  font-size: 13px;
  cursor: pointer;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn-del:hover { background: #C62828; }

/* ---------- GEOMETRY schematic ---------- */
.schematic-box {
  display: flex;
  justify-content: center;
  margin: 16px 0;
  padding: 12px;
  background: #fafafa;
  border-radius: 4px;
}
#shapeSvg {
  width: 100%;
  max-width: 300px;
  height: 220px;
}

/* ---------- SECTION table ---------- */
.section-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 12px;
  font-size: 13px;
}
.section-table th {
  background: #B2DFDB;
  color: #004D40;
  padding: 8px 6px;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
}
.section-table td {
  padding: 6px;
  border-bottom: 1px solid #eee;
  background: #E3F2FD;
}
.section-table tr:nth-child(even) td { background: #F5F5F5; }
.section-table td select,
.section-table td input {
  padding: 4px 6px;
  border: 1px solid #ccc;
  border-radius: 3px;
  font-size: 12px;
  width: 100%;
  background: #fff;
}
.section-table td input[type=number] { text-align: center; }
.section-table td.col-sand { width: 50px; text-align: center; }
.section-table td.col-sand input[type=checkbox] {
  width: 16px; height: 16px; margin: 0; cursor: pointer;
}
.sand-check {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
}
.add-col { width: 40px; text-align: center; }

/* Section preview (layer cross-section) */
.section-preview {
  margin: 12px 0;
  padding: 10px 0;
}
.preview-label {
  text-align: center;
  font-size: 12px;
  color: #555;
  margin: 4px 0;
}
#sectionPreview {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 0 40px;
  position: relative;
}
.layer-row {
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
}
.layer-label {
  position: absolute;
  left: -42px;
  font-size: 10px;
  color: #666;
  width: 40px;
  text-align: right;
}
.layer-bar { flex: 1; }
.layer-bar.glass   { background: #4DD0E1; }
.layer-bar.cavity  { background: #ECEFF1; border-top: 1px dashed #B0BEC5; border-bottom: 1px dashed #B0BEC5; }
.layer-bar.pvb     { background: #212121; }
.layer-bar.sg      { background: #37474F; }
.layer-bar.eva     { background: #455A64; }

/* ---------- ACTIONS blocks ---------- */
.action-block {
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  padding: 12px 14px;
  margin-bottom: 14px;
  background: #fafafa;
}
.action-block legend {
  padding: 0 8px;
  font-weight: 600;
  color: #333;
  font-size: 13px;
}

.toggle-group {
  display: flex;
  margin: 10px 0;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid #1565C0;
}
.toggle-btn {
  flex: 1;
  padding: 10px;
  border: none;
  background: #fff;
  color: #1565C0;
  cursor: pointer;
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.3px;
}
.toggle-btn.active {
  background: #1565C0;
  color: #fff;
}

.advanced-panel {
  margin-top: 12px;
  padding: 10px;
  background: #fff;
  border-radius: 4px;
  border: 1px solid #eee;
}
.advanced-panel summary {
  cursor: pointer;
  font-weight: 600;
  color: #333;
  padding: 4px 0;
  user-select: none;
}
.advanced-panel summary::-webkit-details-marker { display: none; }

/* ---------- ALTITUDE TWO-DIRECTION LAYOUT ---------- */
.alt-dir-block {
  background: #f9f9f9;
  border: 1px solid #e8e8e8;
  border-radius: 4px;
  padding: 8px 10px 4px;
  margin-bottom: 8px;
}
.alt-dir-label {
  font-size: 11px;
  font-weight: 700;
  margin-bottom: 6px;
}
.alt-dir-label.pos { color: #1565C0; }
.alt-dir-label.neg { color: #C62828; }
.alt-dir-row { margin-bottom: 0; }
.field-result input {
  background: #E3F2FD;
  font-weight: 600;
  color: #0D47A1;
}
.formula-hint {
  font-size: 10px;
  color: #888;
  font-weight: 400;
  margin-left: 8px;
}

/* ---------- COMPUTED DISPLAY ROW ---------- */
.computed-row {
  margin: 4px 0 8px;
  padding: 6px 10px;
  background: #E3F2FD;
  border-left: 3px solid #1565C0;
  border-radius: 0 4px 4px 0;
  font-size: 12px;
  color: #444;
  line-height: 1.6;
}
.computed-val {
  font-weight: 700;
  color: #0D47A1;
}

/* ---------- NOTES ---------- */
.note {
  font-size: 11px;
  color: #666;
  background: #FFF8E1;
  border-left: 3px solid #FFC107;
  padding: 8px 10px;
  border-radius: 2px;
  margin: 12px 0;
  line-height: 1.5;
}

/* ---------- RESULTS PANEL ---------- */
.results-panel {
  background: #fff;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  padding: 0;
  min-height: 500px;
  overflow: hidden;
}
.muted { color: #999; font-style: italic; padding: 20px; display: block; }
.status-pass { color: #2E7D32; font-weight: bold; }
.status-fail { color: #C62828; font-weight: bold; padding: 20px; display: block; }

/* ----- Result sub-tabs ----- */
.result-subtabs {
  display: flex;
  border-bottom: 1px solid #e0e0e0;
  background: #fff;
}
.result-subtab {
  flex: 1;
  background: transparent;
  border: none;
  padding: 14px 8px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  color: #555;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  border-bottom: 3px solid transparent;
  transition: all 0.15s;
  font-family: inherit;
}
.result-subtab:hover { background: #f7f9fc; }
.result-subtab.active {
  color: #1565C0;
  border-bottom-color: #E53935;
}
.rtab-icon { font-size: 16px; }

.result-subpanel {
  display: none;
  padding: 20px;
  max-height: 75vh;
  overflow-y: auto;
}
.result-subpanel.active { display: block; }

/* ----- Summary banner ----- */
.summary-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-radius: 4px;
  margin-bottom: 20px;
  font-size: 15px;
  font-weight: 600;
}
.summary-banner.ok  { background: #E8F5E9; color: #2E7D32; border-left: 4px solid #43A047; }
.summary-banner.bad { background: #FFEBEE; color: #C62828; border-left: 4px solid #E53935; }
.banner-icon { font-size: 22px; }

.summary-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.summary-table td {
  padding: 10px 6px;
  border-bottom: 1px solid #f0f0f0;
  vertical-align: middle;
}
.summary-table td:first-child {
  color: #555;
  white-space: nowrap;
  padding-right: 14px;
}
.summary-table td.bar-cell { width: 100%; }

.summary-footer {
  margin-top: 18px;
  padding-top: 12px;
  border-top: 1px solid #eee;
  font-size: 12px;
}
.summary-footer a { color: #1565C0; text-decoration: none; }
.summary-footer a:hover { text-decoration: underline; }

/* ----- Utilisation bars (used by summary + combo tables) ----- */
.util-bar {
  position: relative;
  height: 18px;
  background: #f0f0f0;
  border-radius: 2px;
  overflow: hidden;
  min-width: 120px;
}
.util-fill {
  height: 100%;
  transition: width 0.25s ease-out;
}
.util-fill.ok   { background: #1976D2; }
.util-fill.warn { background: #FB8C00; }
.util-fill.bad  { background: #E53935; }
.util-text {
  position: absolute;
  left: 6px;
  top: 1px;
  font-size: 11px;
  font-weight: 600;
  color: #222;
  font-family: "Consolas", "Monaco", monospace;
}

/* ----- Combination tables (displacement / stress design) ----- */
.combo-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.combo-table th {
  text-align: left;
  padding: 8px 6px;
  border-bottom: 2px solid #e0e0e0;
  color: #555;
  font-weight: 500;
  background: #fafbfc;
  position: sticky;
  top: 0;
}
.combo-table th.num { text-align: right; }
.combo-table td {
  padding: 6px;
  border-bottom: 1px solid #f2f2f2;
  vertical-align: middle;
}
.combo-table td.combo-name {
  font-family: "Consolas", "Monaco", monospace;
  font-weight: 600;
  color: #1565C0;
  white-space: nowrap;
}
.combo-table td.combo-name .combo-formula {
  font-weight: 400;
  font-size: 10px;
  color: #666;
  margin-top: 2px;
  font-family: "Segoe UI", Roboto, sans-serif;
  white-space: normal;
  max-width: 260px;
}
.gov-combo {
  font-size: 11px;
  color: #555;
  margin-top: 3px;
  font-family: "Segoe UI", Roboto, sans-serif;
}
.gov-combo b {
  color: #1565C0;
  font-family: "Consolas", "Monaco", monospace;
}
.combo-table td.num {
  text-align: right;
  font-family: "Consolas", "Monaco", monospace;
}
.combo-table td.bar-cell { min-width: 150px; }
.combo-table tr:hover { background: #fafbfc; }
.combo-table tr.combo-type-header td {
  background: #1565C0;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 5px 6px;
  letter-spacing: 0.3px;
}
.combo-table tr.row-fail td { background: #FFF3F3; }
.combo-table .defl-vals {
  font-size: 10px;
  color: #777;
  margin-top: 2px;
  font-family: "Consolas", "Monaco", monospace;
}

/* ---------- FOOTER ---------- */
.footer {
  text-align: center;
  padding: 14px;
  font-size: 11px;
  color: #888;
  border-top: 1px solid #ddd;
  margin-top: 20px;
}
