/* ================================================================
   Weld Calculator v1.0 — style.css
   Light Industrial theme — unified with Weld Map & Balloon tools
================================================================ */

/* ── DESIGN TOKENS ───────────────────────────────────────────── */
:root {
  --bg:           #eef3f7;
  --surface:      #ffffff;
  --panel:        #f8fbfd;
  --surface-soft: #f8fbfd;
  --border:       #d6e0e8;
  --border-lt:    #bfd0dc;
  --text:         #233243;
  --muted:        #627588;
  --dim:          #7b8d9f;
  --primary:      #2f698f;
  --primary-dark: #244f6d;
  --accent:       #2f698f;
  --accent-dk:    #244f6d;
  --red:          #b42318;
  --green:        #23654d;
  --amber:        #996600;
  --purple:       #6d4fb3;
  --teal:         #1f7a74;
  --shadow:       0 14px 28px rgba(15,23,42,0.08);
  --shadow-soft:  0 6px 14px rgba(15,23,42,0.06);
  --shadow-strong:0 20px 48px rgba(15,23,42,0.18);
  --mono:  ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --sans:  "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --radius:    10px;
  --radius-lg: 16px;
}

.weld-calc-app *, .weld-calc-app *::before, .weld-calc-app *::after { box-sizing: border-box; margin: 0; padding: 0; }
.weld-calc-app input[type="file"] { display: none; }
.weld-calc-app .hidden { display: none !important; }

/* ── PAGE WRAPPER (was body) ── */
.weld-calc-app {
  font-family: var(--sans);
  color: var(--text);
}

/* ── HEADER (kept for backward-compat; calc no longer renders its own header inside the site) ── */
.weld-calc-app header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  height: 52px;
  background: linear-gradient(135deg, #24384b 0%, #31556f 58%, #4f7692 100%);
  box-shadow: var(--shadow-strong);
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
}
.hdr-logo { font-size: 17px; font-weight: 800; letter-spacing: -0.3px; color: #f8fbfd; white-space: nowrap; }
.hdr-logo .iq { color: #9ed0ef; }
.hdr-logo .q-wrap { position: relative; display: inline-block; }
.hdr-logo .q-cross { position: absolute; left: 48.5%; top: 51%; width: 0.40em; height: 0.40em; transform: translate(-50%,-50%); pointer-events: none; }
.weld-calc-app .beta-badge { display: inline-block; padding: 2px 7px; margin-left: 2px; background: #f59e0b; color: #1a1200; border-radius: 999px; font-family: var(--sans); font-size: 9.5px; font-weight: 900; letter-spacing: 0.08em; vertical-align: middle; text-transform: uppercase; }
.hdr-sub { font-size: 11px; color: #d7e4ef; font-family: var(--mono); white-space: nowrap; }
.hdr-meta { font-size: 11px; color: #8fafc6; font-family: var(--mono); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hdr-right { margin-left: auto; display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

/* ── TOOLBAR ── */
.weld-calc-app .toolbar {
  display: flex; flex-wrap: wrap; gap: 10px; padding: 12px 28px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 4px rgba(15,23,42,0.04); align-items: center;
  position: sticky; top: 64px; z-index: 49;        /* sits just below Base.astro's site header (64 px, z-index 50) */
}
.weld-calc-app .toolbar-group { padding: 6px 12px; gap: 6px; }
.toolbar-group {
  display: flex; align-items: center; gap: 4px;
  padding: 5px 8px; background: var(--panel);
  border: 1px solid var(--border); border-radius: var(--radius);
}
.tg-label {
  font-size: 11.5px; font-weight: 800; font-family: var(--sans);
  color: var(--accent-dk); letter-spacing: .02em;
  margin-right: 4px; white-space: nowrap;
}

/* ── BUTTONS ── */
.weld-calc-app .btn,
.weld-calc-app button.btn,
.weld-calc-app .file-label,
.weld-calc-app label.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  padding: 6px 12px; min-height: 32px; border: 1px solid var(--border-lt);
  border-radius: 8px; background: var(--surface); color: var(--text);
  font-family: var(--sans); font-size: 12.5px; font-weight: 600;
  cursor: pointer; white-space: nowrap; letter-spacing: 0;
  text-transform: none;                                /* overrides the generic `label { text-transform: uppercase }` rule */
  margin: 0;                                           /* overrides `label { margin-bottom: 4px }` */
  transition: border-color .15s, color .15s, background .15s;
  text-decoration: none;
}
.btn:hover, .file-label:hover { border-color: var(--accent); color: var(--accent); background: #eef5f9; }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 700; }
.btn.primary:hover { background: var(--accent-dk); border-color: var(--accent-dk); color: #fff; }
.btn.active  { background: rgba(47,105,143,.12); color: var(--accent); border-color: var(--accent); }
.btn.danger  { color: var(--red); border-color: #f0c8c8; }
.btn.danger:hover { background: #fff7f7; border-color: var(--red); }
.btn.teal    { color: var(--teal); border-color: #b8d9d5; }
.btn.teal:hover { background: #e9f6f4; }

/* ── CONTENT WRAPPER ── */
.weld-calc-app .content-wrap { max-width: 1440px; margin: 0 auto; padding: 20px 28px 32px; }

/* ── PROJECT CARD ── */
.project-card {
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  overflow: hidden; margin-bottom: 14px;
  background: var(--surface); box-shadow: var(--shadow-soft);
}
.project-card-title {
  padding: 11px 16px; font-size: 12px; font-weight: 800; font-family: var(--sans);
  letter-spacing: .03em; color: var(--accent-dk);
  background: var(--panel); border-bottom: 1px solid var(--border);
}
.project-card-body {
  padding: 14px; display: grid;
  grid-template-columns: repeat(5, minmax(0,1fr));
  gap: 12px 14px; align-items: end;
}
.project-field { display: flex; flex-direction: column; gap: 5px; }

/* ── FORMULA HELP PANEL ── */
.formula-help-panel {
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  overflow: hidden; margin-bottom: 14px;
  background: var(--surface); box-shadow: var(--shadow-soft);
}
.formula-help-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 12px; padding: 10px 14px; background: #edf5fb; border-bottom: 1px solid var(--border);
}
.formula-help-header h3 { margin: 0 0 2px; color: var(--primary); font-size: 13px; font-weight: 700; }
.formula-help-header p  { margin: 0; color: var(--muted); font-size: 11px; }
.formula-help-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 12px; padding: 14px; align-items: stretch; }
.formula-card { border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); padding: 11px 12px; }
.formula-card h4 { margin: 0 0 7px; color: var(--primary); font-size: 12px; font-weight: 700; }
.formula-card p  { margin: 4px 0; color: var(--muted); font-size: 12px; line-height: 1.4; }
.formula-card strong { color: var(--text); }
.formula-wide { grid-column: 1/-1; }

/* ── SECTION CARDS ── */
.controls-card {
  display: grid; grid-template-columns: repeat(4, minmax(0,1fr));
  gap: 14px; margin-bottom: 14px; align-items: stretch;
}
.section-card {
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 14px; background: var(--surface); box-shadow: var(--shadow-soft);
  display: flex; flex-direction: column;
}
.section-title {
  position: relative; padding: 0 0 10px 14px; margin: 0 0 14px;
  border-bottom: 1px solid var(--border); color: var(--accent-dk);
  font-size: 12px; font-weight: 800; font-family: var(--sans);
  letter-spacing: .03em;
}
.section-title::before {
  content: ""; position: absolute; left: 0; top: 1px; bottom: 8px;
  width: 3px; border-radius: 999px;
  background: linear-gradient(180deg, #6e99b8 0%, var(--primary) 100%);
}

/* ── FORM ELEMENTS ── */
.weld-calc-app .input-group > label,
.weld-calc-app .project-field > label {
  display: block; font-size: 10.5px; font-weight: 700; font-family: var(--mono);
  color: #496073; margin-bottom: 4px; text-transform: uppercase; letter-spacing: .05em; line-height: 1.15;
}
.weld-calc-app input, .weld-calc-app select, .weld-calc-app textarea {
  width: 100%; padding: 9px 13px; border: 1px solid var(--border-lt);
  border-radius: var(--radius); background: var(--panel); color: var(--text);
  font-family: var(--sans); font-size: 13.5px; font-weight: 600;
  outline: none; transition: border-color .15s, box-shadow .15s;
  box-shadow: inset 0 1px 1px rgba(255,255,255,0.65);
}
.weld-calc-app input:focus, .weld-calc-app select:focus { border-color: #78a4c0; box-shadow: 0 0 0 3px rgba(82,132,164,0.15); }
.weld-calc-app input:hover:not(:focus), .weld-calc-app select:hover:not(:focus) { border-color: #9fb8c9; }
.weld-calc-app input[readonly] { background: #edf5fb; border-color: #c7ddee; color: #274560; font-weight: 800; cursor: default; padding: 9px 14px; }
.weld-calc-app .result-grid input[readonly] { padding-right: 16px; }

.input-grid, .result-grid {
  display: grid; grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 10px 12px; flex: 1; align-content: start;
}
.input-group { display: flex; flex-direction: column; gap: 5px; }
.input-group label { min-height: 2.2em; display: flex; align-items: flex-end; gap: 5px; flex-wrap: wrap; }
.unit-tag { color: var(--muted); font-weight: 400; font-size: 11px; line-height: 1.2; }
.result-grid .input-group label { min-height: auto; align-items: center; }
.result-grid input[readonly] { text-align: right; font-variant-numeric: tabular-nums; }
.result-primary input[readonly] { background: #eaf7ef; border-color: #b9e0ca; color: var(--green); }
#outSellPrice { background: #f0fbf5 !important; border-color: #92d3af !important; color: #165c40 !important; font-size: 14px !important; }

/* Fillet / stitch accents */
.fillet-only-field label, .stitch-field label { color: #8a5a00; }
.fillet-only-field select, .stitch-field input { background: #fffdf5; border-color: #e4c56f; }
#calculatedStitchCount[readonly] { background: #fff8e8; border-color: #f59e0b; color: #78350f; font-weight: 800; }

/* Show sketch button */
.sketch-open-group label { color: var(--primary); }
.show-sketch-button {
  width: 100%; padding: 8px 10px; min-height: 30px;
  border: 1px solid #3d84b1; border-radius: var(--radius);
  background: linear-gradient(180deg, #4e93bc 0%, var(--primary) 100%);
  color: #fff; font-family: var(--sans); font-size: 12px; font-weight: 700;
  cursor: pointer; transition: filter .15s;
}
.show-sketch-button:hover { filter: brightness(0.93); }

/* ── LINE ITEMS ── */
.line-items-panel {
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  overflow: hidden; background: var(--surface); box-shadow: var(--shadow-soft); margin-bottom: 14px;
}
.line-items-header {
  display: flex; justify-content: space-between; align-items: center;
  gap: 16px; padding: 10px 14px; background: var(--panel); border-bottom: 1px solid var(--border);
}
.line-items-header h3 { margin: 0 0 2px; color: var(--text); font-size: 13px; font-weight: 700; }
.line-items-header p  { margin: 0; color: var(--muted); font-size: 11px; }
.line-items-actions {
  display: grid; grid-template-columns: minmax(200px,1fr) minmax(200px,1fr) auto auto;
  gap: 8px; align-items: end; padding: 12px 14px; border-bottom: 1px solid var(--border);
}
.line-items-hint { grid-column: 1/-1; color: var(--muted); font-size: 11px; font-family: var(--mono); }
.line-items-table-wrap { overflow-x: auto; }
.line-items-table {
  width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 12px;
}
.line-items-table th, .line-items-table td { border-bottom: 1px solid var(--border); padding: 7px 8px; vertical-align: middle; }
.line-items-table th {
  background: linear-gradient(180deg, #334d64 0%, #2b4358 100%);
  color: #eff5f9; font-size: 10px; font-weight: 700; font-family: var(--mono);
  text-transform: uppercase; letter-spacing: .03em; white-space: nowrap;
  position: sticky; top: 0; z-index: 1;
}
.line-items-table tbody tr:nth-child(even) td { background: var(--panel); }
.line-items-table tbody tr:hover td { background: #eef5fa; }
.line-items-table tfoot td { background: #eef8f2; color: var(--green); font-weight: 800; border-top: 2px solid #b8ddc7; }
.col-index { width: 36px; text-align: center; }
.col-description { width: 180px; font-weight: 600; color: #22384d; line-height: 1.3; }
.col-notes { width: 180px; color: var(--muted); line-height: 1.3; }
.col-actions { width: 88px; text-align: center; white-space: nowrap; }
.numeric-cell { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.strong-sell, #lineTotalSell { color: var(--green) !important; font-weight: 800 !important; }
.empty-line-items { text-align: center !important; color: var(--dim); font-style: italic; padding: 18px !important; }
.line-pattern-note { color: var(--amber); font-weight: 700; display: inline-block; margin-top: 2px; }

.edit-line-button {
  display: inline-flex; align-items: center; border: 1px solid #bfd5e4;
  background: #edf5fb; color: #24506e; border-radius: 6px;
  padding: 4px 7px; font-size: 11px; font-weight: 700; cursor: pointer; margin-right: 3px;
}
.edit-line-button:hover { background: #dceef8; }
.remove-line-button {
  display: inline-flex; align-items: center; border: 1px solid #f0c4c4;
  background: #fff7f7; color: var(--red); border-radius: 6px;
  padding: 4px 7px; font-size: 11px; font-weight: 700; cursor: pointer;
}
.remove-line-button:hover { background: #fee2e2; }

/* ── SKETCH MODAL ── */
.sketch-modal {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(18,31,43,0.75); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.sketch-modal-inner {
  width: min(1120px,88vw); height: min(74vh,760px);
  background: var(--surface); border-radius: var(--radius-lg);
  display: flex; flex-direction: column; overflow: hidden; box-shadow: var(--shadow-strong);
}
.sketch-modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; background: linear-gradient(180deg,#fdfefe,#f2f7fa);
  border-bottom: 1px solid var(--border); min-height: 50px;
}
.sketch-modal-header h3 { margin: 0; color: var(--primary); font-size: 14px; font-weight: 700; }
.modal-svg-container {
  flex: 1; min-height: 0; padding: 24px;
  background: linear-gradient(0deg,rgba(47,105,143,.03),rgba(47,105,143,.03)),
    linear-gradient(90deg,rgba(139,164,183,.12) 1px,transparent 1px),
    linear-gradient(rgba(139,164,183,.12) 1px,transparent 1px), #f8fbfd;
  background-size: auto, 28px 28px, 28px 28px, auto;
  display: flex; justify-content: center; align-items: center; overflow: hidden;
}
.modal-svg-container svg { width: 100%; height: 100%; display: block; }

/* SVG drawing styles */
.plate     { fill: #dfe8ef; stroke: #2c4358; stroke-width: 2; stroke-linejoin: round; }
.weld      { fill: #8ca7ba; stroke: #203547; stroke-width: 2; stroke-linejoin: round; }
.dim-line  { stroke: var(--primary); stroke-width: 1.5; fill: none; }
.dim-text  { fill: #2b5e80; font-size: 14px; font-weight: 800; font-family: monospace; }
.dim-guide { stroke: #708799; stroke-width: 1.5; stroke-dasharray: 4,4; opacity: .7; }
.angle-line{ stroke: #203547; stroke-width: 1.5; fill: none; }
.angle-text{ fill: #203547; font-size: 16px; font-weight: 700; font-family: Georgia,serif; font-style: italic; }

/* ── FOOTER ── */
.app-footer {
  text-align: center; color: #8ba0b2; font-size: 11px; font-weight: 700;
  font-family: var(--mono); letter-spacing: .05em; text-transform: uppercase; margin-bottom: 20px;
}

/* ── PRINT (summary section) ── */
.print-summary { display: none; }
.print-title-row {
  display: grid; grid-template-columns: 1.2fr 1.4fr 1fr; gap: 12px; align-items: start;
  border-bottom: 2px solid #1e293b; padding-bottom: 10px; margin-bottom: 12px;
}
.print-brand-block { display: flex; align-items: center; gap: 14px; }
.print-weldiq-mark {
  display: inline-block; font-size: 22px; font-weight: 800;
  color: #24384b; line-height: 1; letter-spacing: -0.01em;
  white-space: nowrap;
}
.print-weldiq-mark .print-iq { color: #2f698f; }
.print-weldiq-mark .print-q-wrap { position: relative; display: inline-block; }
.print-weldiq-mark .print-q-cross {
  position: absolute; left: 48.5%; top: 51%;
  width: 0.40em; height: 0.40em;
  transform: translate(-50%, -50%); pointer-events: none;
}
.print-company-name { color: #0f172a; font-size: 15px; font-weight: 800; }
.print-title-row h1 { margin: 0 0 5px; color: #0f172a; font-size: 20px; line-height: 1.1; }
.print-title-row p  { margin: 2px 0; color: #334155; font-size: 11px; }
.print-job-box { border: 1px solid #cbd5e1; border-radius: 8px; padding: 10px; background: #f8fafc; }
.print-job-box p { margin: 2px 0; font-size: 11px; }
.print-grid { display: none; }
.print-current-calc { margin: 4px 0 14px; }
.print-current-calc h3 { margin: 0 0 7px; color: #0f172a; font-size: 14px; }
.print-kv-table { margin-bottom: 8px; }
.print-kv-table th { width: 18%; text-align: left; }
.print-kv-table td { width: 32%; }
.print-sell-th, .print-sell-td { background: #ecfdf3 !important; color: #14532d !important; }
.print-sell-td { font-weight: 800 !important; }
.print-line-items-section { margin-top: 12px; }
.print-line-items-section h3 { margin: 0 0 7px; color: #0f172a; font-size: 14px; }
.print-line-items-table, .simple-print-table { width: 100%; border-collapse: collapse; font-size: 10px; }
.print-line-items-table th, .simple-print-table th {
  background: #e2e8f0 !important; color: #0f172a !important;
  font-weight: 800; border: 1px solid #94a3b8; padding: 5px;
}
.print-line-items-table td, .simple-print-table td { border: 1px solid #cbd5e1; padding: 5px; vertical-align: top; }
.print-line-items-table tfoot td { background: #ecfdf3 !important; color: #14532d !important; font-weight: 800; border-top: 2px solid #86efac; }
.print-note { margin-top: 12px; padding-top: 8px; border-top: 1px solid #cbd5e1; color: #475569; font-size: 11px; line-height: 1.4; }

/* ── RESPONSIVE ── */
@media (max-width: 1200px) {
  .controls-card { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .project-card-body { grid-template-columns: repeat(3,minmax(0,1fr)); }
  .formula-help-grid { grid-template-columns: repeat(2,1fr); }
  .line-items-table { table-layout: auto; min-width: 1100px; }
}
@media (max-width: 900px) {
  .content-wrap { padding: 12px 14px 20px; }
  .line-items-actions { grid-template-columns: 1fr 1fr; }
  .project-card-body { grid-template-columns: repeat(2,minmax(0,1fr)); }
}
@media (max-width: 700px) {
  .controls-card { grid-template-columns: 1fr; }
  .project-card-body { grid-template-columns: 1fr; }
  .formula-help-grid { grid-template-columns: 1fr; }
  .line-items-actions { grid-template-columns: 1fr; }
  .sketch-modal { padding: 10px; }
  .sketch-modal-inner { width: 100%; height: min(78vh,680px); }
  .input-group label { min-height: auto; }
}

/* ── PRINT MEDIA ── */
@media print {
  @page { size: A4; margin: 20mm 18mm 22mm 18mm; }                 /* generous, professional document margins */
  body { background: #fff !important; color: #0f172a !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  /* Hide the calc's internal chrome + everything from the wrapping site */
  header, .site-header, .site-footer, .weld-calc-page-head,
  .weld-calc-app .toolbar, .weld-calc-app .content-wrap,
  .sketch-modal, .app-footer { display: none !important; }
  /* Show ONLY the WeldIQ-branded print summary */
  .print-summary { display: block !important; padding: 0; margin: 0; }
  .print-title-row { display: grid !important; grid-template-columns: 1.2fr 1.4fr 1fr !important; }
  .print-grid { display: none !important; }
  .print-line-items-section { display: block; }
  /* Avoid awkward page breaks in the middle of small tables */
  .print-kv-table, .print-line-items-table { page-break-inside: avoid; }
}
