/* ============================================================
   PD 8010 Wall Thickness Calculator — Styles
   ============================================================ */

:root {
  --navy:       #0f2d4e;
  --navy-light: #1a4068;
  --blue:       #1e6faa;
  --blue-light: #2980b9;
  --accent:     #e8a020;
  --green:      #27ae60;
  --red:        #e74c3c;
  --orange:     #e67e22;
  --bg:         #edf1f6;
  --bg-card:    #ffffff;
  --border:     #d1d9e0;
  --text:       #1a2b3c;
  --text-muted: #5a7090;
  --shadow:     0 2px 8px rgba(0,0,0,0.10);
  --radius:     8px;
}

/* Tool page overrides — site header is provided by site.css */
:root { --tool-sub-h: 52px; --chrome-h: calc(73px + var(--tool-sub-h)); }

body.tool-page {
  font-family: 'Open Sans', 'Segoe UI', system-ui, sans-serif;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ── Tool Sub-header ──────────────────────────────────────────── */
.tool-subheader {
  background: var(--navy);
  height: var(--tool-sub-h);
  display: flex;
  align-items: center;
  padding: 0 24px;
  position: sticky;
  top: 73px;
  z-index: 90;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
}

.tool-subheader-inner {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.tool-title-area {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}

.tool-breadcrumb {
  font-size: 11px;
  color: rgba(255,255,255,0.45);
  margin-bottom: 1px;
}
.tool-breadcrumb a { color: rgba(255,255,255,0.45); text-decoration: none; }
.tool-breadcrumb a:hover { color: rgba(255,255,255,0.75); }

.tool-name {
  font-size: 15px;
  font-weight: 600;
  color: white;
  letter-spacing: 0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tool-subheader-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* Tool nav (Tables / Calculators) */
.tool-nav > ul {
  list-style: none;
  display: flex;
  gap: 2px;
}

.tool-nav li { position: relative; }

.tool-nav-link {
  display: block;
  padding: 5px 12px;
  color: rgba(255,255,255,0.8);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.15s;
  white-space: nowrap;
  user-select: none;
}
.tool-nav li:hover > .tool-nav-link,
.tool-nav li.open > .tool-nav-link { background: rgba(255,255,255,0.12); color: white; }

.tool-nav-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  background: white;
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.15);
  min-width: 210px;
  list-style: none;
  z-index: 500;
  padding: 4px 0;
}
.tool-nav li.open > .tool-nav-dropdown { display: block; }

.tool-nav-dropdown a {
  display: block;
  padding: 9px 16px;
  font-size: 13px;
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
  transition: background 0.1s;
}
.tool-nav-dropdown a:hover { background: #f0f5fb; color: var(--blue); }

.btn-ghost-tool {
  background: transparent;
  color: rgba(255,255,255,0.8);
  border: 1px solid rgba(255,255,255,0.3);
  padding: 5px 14px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  white-space: nowrap;
  transition: background 0.15s;
}
.btn-ghost-tool:hover { background: rgba(255,255,255,0.1); color: white; }

.header-inner {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header-title {
  display: flex;
  align-items: center;
  gap: 14px;
}

.header-title h1 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.standard-badge {
  background: var(--accent);
  color: var(--navy);
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 4px;
  letter-spacing: 0.5px;
}

/* ── Nav menu ────────────────────────────────────────────────── */
.app-nav { display: flex; align-items: center; }

.nav-list {
  list-style: none;
  display: flex;
  gap: 4px;
}

.nav-item {
  position: relative;
}

.nav-link {
  display: block;
  padding: 6px 14px;
  color: rgba(255,255,255,0.85);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border-radius: 5px;
  transition: background 0.15s;
  white-space: nowrap;
  user-select: none;
}
.nav-item:hover > .nav-link { background: rgba(255,255,255,0.12); color: white; }

.nav-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  background: white;
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.15);
  min-width: 200px;
  list-style: none;
  z-index: 500;
  padding: 4px 0;
  margin-top: 2px;
}
.nav-item:hover > .nav-dropdown,
.nav-item.open > .nav-dropdown { display: block; }

.nav-dropdown-item {
  display: block;
  padding: 9px 16px;
  font-size: 13px;
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
  transition: background 0.1s;
}
.nav-dropdown-item:hover { background: #f0f5fb; color: var(--blue); }

/* ── B36.10 Table View ───────────────────────────────────────── */
.table-view-header {
  background: white;
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
}
.table-view-header h2 {
  font-size: 16px;
  color: var(--navy);
  font-weight: 700;
}

.table-view-body {
  padding: 20px 24px;
  height: calc(100vh - var(--chrome-h) - 53px);
  overflow: auto;
}

.table-view-body .table-scroll {
  overflow: visible;
}

.table-view-body .data-table td,
.table-view-body .data-table th { padding: 7px 11px; font-size: 12px; }

.table-view-body .data-table thead tr:first-child th {
  position: sticky;
  top: 0;
  z-index: 11;
}

.table-view-body .data-table thead tr.filter-row th {
  position: sticky;
  z-index: 10;
  /* top is set dynamically by JS after first row height is known */
}

.badge-yes { background: #d4f5e2; color: #1a7a3f; border: 1px solid #9de0b8; }
.badge-no  { background: #f0f0f0; color: #999;    border: 1px solid #ddd; }

.filter-row th { background: #1a4068; padding: 4px 6px; }

.col-filter {
  width: 100%;
  padding: 4px 6px;
  font-size: 11px;
  border: 1px solid #4a7aaa;
  border-radius: 4px;
  background: #0f2d4e;
  color: white;
  font-family: inherit;
}
.col-filter::placeholder { color: rgba(255,255,255,0.45); }
.col-filter:focus {
  outline: none;
  border-color: var(--accent);
  background: #163654;
}
.col-filter option { background: #0f2d4e; color: white; }

/* ── Layout ──────────────────────────────────────────────────── */
.app-body {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 0;
  min-height: calc(100vh - var(--chrome-h));
}

/* ── Input Panel ─────────────────────────────────────────────── */
.input-panel {
  background: #f0f3f7;
  border-right: 1px solid var(--border);
  padding: 20px 16px;
  overflow-y: auto;
  height: calc(100vh - var(--chrome-h));
  position: sticky;
  top: 58px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Unit toggle row */
.unit-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.unit-label-text { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.toggle-group { display: flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.toggle-btn {
  padding: 5px 12px;
  background: white;
  border: none;
  cursor: pointer;
  font-size: 12px;
  color: var(--text-muted);
  transition: background 0.15s, color 0.15s;
}
.toggle-btn + .toggle-btn { border-left: 1px solid var(--border); }
.toggle-btn.active { background: var(--navy); color: white; font-weight: 600; }

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.input-section { padding: 14px 16px; }

.section-heading {
  font-size: 13px;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.step-num {
  width: 20px; height: 20px;
  background: var(--blue);
  color: white;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Form elements */
.form-group { margin-bottom: 10px; }
.form-group:last-child { margin-bottom: 0; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.unit-hint { font-weight: 400; color: #8fa8c0; }

input[type="number"],
input[type="text"],
select,
textarea {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 13px;
  color: var(--text);
  background: white;
  transition: border-color 0.15s, box-shadow 0.15s;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(30, 111, 170, 0.12);
}
textarea { resize: vertical; }

.field-readonly {
  background: #f4f7fb;
  color: var(--text-muted);
  cursor: default;
}

.info-note {
  font-size: 11px;
  color: var(--text-muted);
  background: #f0f6ff;
  border: 1px solid #c8dff0;
  border-radius: 4px;
  padding: 5px 9px;
  margin-top: 4px;
}

.btn-calc {
  margin-top: 4px;
  width: 100%;
  padding: 12px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  transition: background 0.15s, transform 0.1s;
}
.btn:active { transform: scale(0.98); }

.btn-primary { background: var(--blue); color: white; }
.btn-primary:hover { background: var(--blue-light); }

.btn-secondary { background: #e8f0f8; color: var(--navy); border: 1px solid #c0d4e8; }
.btn-secondary:hover { background: #d0e4f4; }

.btn-ghost { background: transparent; color: rgba(255,255,255,0.85); border: 1px solid rgba(255,255,255,0.3); }
.btn-ghost:hover { background: rgba(255,255,255,0.1); }

.btn-icon {
  background: none; border: none; cursor: pointer;
  font-size: 22px; color: var(--text-muted); line-height: 1;
  padding: 4px 8px;
}
.btn-icon:hover { color: var(--red); }

.btn-danger { background: #fdecea; color: var(--red); border: 1px solid #f5c6c2; }
.btn-danger:hover { background: #fad6d3; }

/* ── Results Panel ───────────────────────────────────────────── */
.results-panel {
  padding: 20px 20px;
  overflow-y: auto;
  height: calc(100vh - var(--chrome-h));
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.results-placeholder {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  text-align: center;
  gap: 16px;
}
.placeholder-icon { font-size: 56px; opacity: 0.2; }
.results-placeholder p { font-size: 15px; line-height: 1.6; }

#resultsContent { display: flex; flex-direction: column; gap: 16px; }

/* Summary row */
.summary-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}
.summary-card {
  padding: 16px;
  text-align: center;
}
.summary-label { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px; }
.summary-value { font-size: 32px; font-weight: 700; color: var(--navy); line-height: 1; }
.summary-value.small { font-size: 22px; }
.summary-unit { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.highlight-card { border-color: var(--green); background: #f2fbf5; }
.highlight-card .summary-value { color: var(--green); }

/* Results sections */
.results-section { padding: 18px 20px; }
.results-section h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--bg);
}

/* Formula box */
.formula-box {
  background: #f4f8ff;
  border: 1px solid #c8daef;
  border-left: 4px solid var(--blue);
  border-radius: 6px;
  padding: 10px 14px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}
.formula-ref { font-size: 11px; color: var(--text-muted); white-space: nowrap; }
.formula-text { font-size: 14px; font-style: italic; color: var(--navy); }

/* Data table */
.table-scroll { overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th {
  background: var(--navy);
  color: white;
  padding: 9px 12px;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.3px;
}
.data-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}
.data-table tbody tr:hover { background: #f5f8fc; }
.data-table tbody tr:last-child td { border-bottom: none; }

.row-recommended { background: #edfaf2 !important; font-weight: 600; }
.row-recommended td { color: #1a7a3f; }
.row-fail td { color: #999; }

/* Badges */
.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.badge-recommended { background: #d4f5e2; color: #1a7a3f; border: 1px solid #9de0b8; }
.badge-pass        { background: #e8f4fd; color: #1a6090; border: 1px solid #b3d8f0; }
.badge-fail        { background: #fdecea; color: #b03030; border: 1px solid #f5c0bc; }

/* Breakdown table */
.breakdown-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.breakdown-table td { padding: 6px 10px; }
.breakdown-table tr:nth-child(even) { background: #fafbfc; }
.breakdown-table .bd-header td {
  background: #edf2f8;
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  padding-top: 10px;
}
.breakdown-table .bd-param td:first-child { color: var(--text-muted); width: 55%; }
.breakdown-table .bd-param td:nth-child(2) { color: var(--text-muted); width: 5%; text-align: center; }
.breakdown-table .bd-param td:last-child { font-weight: 600; color: var(--navy); }
.breakdown-table .bd-result td:last-child { font-weight: 700; font-size: 14px; color: var(--blue); }
.breakdown-table .bd-selected td { background: #edfaf2; }
.breakdown-table .bd-selected td:last-child { color: var(--green); }
.breakdown-table .bd-warn td { background: #fff8e8; }
.breakdown-table .bd-warn td:last-child { color: var(--orange); }

/* Save section */
.save-feedback {
  font-size: 12px;
  margin-left: 10px;
  color: var(--green);
  font-weight: 600;
}

/* ── Modal ───────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-box {
  background: white;
  border-radius: 10px;
  width: 100%;
  max-width: 860px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 16px; color: var(--navy); }
.modal-body { padding: 16px 20px; overflow-y: auto; }
.empty-msg { color: var(--text-muted); font-style: italic; }

/* History cards */
.history-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.history-card:hover { background: #f9fbfc; }
.history-info { flex: 1; min-width: 0; }
.history-ref { font-weight: 700; font-size: 14px; color: var(--navy); margin-bottom: 4px; }
.history-meta { font-size: 12px; color: var(--text-muted); display: flex; flex-wrap: wrap; gap: 12px; }
.history-meta span { display: flex; align-items: center; gap: 4px; }
.history-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* ── Toast ───────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(30px);
  background: var(--navy);
  color: white;
  padding: 10px 22px;
  border-radius: 24px;
  font-size: 13px;
  font-weight: 500;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
  z-index: 300;
  white-space: nowrap;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 860px) {
  .app-body {
    grid-template-columns: 1fr;
  }
  .input-panel {
    height: auto;
    position: static;
  }
  .results-panel {
    height: auto;
  }
  .summary-row {
    grid-template-columns: 1fr 1fr;
  }
}
@media (max-width: 480px) {
  .summary-row { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
}
