/* === CALCULATOR STYLES === */
/* Note: Base resets (box-sizing, fonts, colors) are inherited from nanocode_minimal.css */

/* === LAYOUT === */
.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 16px 40px;
}

.calculator-wrapper {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Scoped to .page (calculator.html) — bare element selectors would otherwise
   leak into index.html, which loads this stylesheet too. */
.page header {
  margin-bottom: 24px;
}

.page header h1 {
  margin: 0 0 8px;
  font-size: 1.9rem;
}

.page header p {
  margin: 0;
  color: var(--muted);
  max-width: 720px;
}

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

.main-layout {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.left-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
}

/* Grid Layout for Calculator Cards */
.input-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: auto auto;
  gap: 16px;
  align-items: start;
}

.input-output-column {
  display: contents;
}

/* Input and summary cards in row 1 */
.input-card,
.summary-card {
  grid-row: 1;
  display: flex;
  flex-direction: column;
  align-self: stretch;
}

/* Result and features cards in row 2 */
.result-card,
.features-card {
  grid-row: 2;
  display: flex;
  flex-direction: column;
  align-self: stretch;
}

/* === CARDS === */
.card,
.result-card,
.summary-card,
.features-card {
  background: linear-gradient(145deg, #111827, #020617);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 16px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.55);
  min-width: 0;
  overflow: hidden;
}

.result-card {
  background: linear-gradient(145deg, #0f1419, #020617);
  padding: 12px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
  flex: 1;
}

/* Card headings */
.card h2,
.summary-card h2,
.features-card h2 {
  margin: 0 0 8px;
  font-size: 1.2rem;
}

.card h3,
.input-card h3 {
  margin: 14px 0 6px;
  font-size: 0.95rem;
}

.input-card h3 {
  margin: 0 0 8px;
  color: var(--accent);
}

/* === FORM ELEMENTS === */
label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 16px;
  font-size: 0.9rem;
}

input[type="text"],
select {
  border-radius: 8px;
  border: 1px solid var(--border);
  padding: 6px 8px;
  background: #020617;
  color: var(--text);
  font-size: 0.9rem;
  outline: none;
  width: 100%;
}

input[type="text"]:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-soft);
}

select {
  cursor: pointer;
}

button {
  /*border-radius: 999px;*/
  border: none;
  padding: 10px 22px;
  background: linear-gradient(135deg, var(--accent), #3b82f6);
  color: #020617;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.95rem;
  /*box-shadow: 0 12px 25px rgba(15, 118, 110, 0.6);*/
  /*transition: transform 0.08s ease-out, box-shadow 0.08s ease-out, filter 0.08s ease-out;*/
}

button:hover {
  /*transform: translateY(-1px);*/
  /*filter: brightness(1.05);*/
  box-shadow: 0 16px 32px rgba(15, 118, 110, 0.7);
}

button:active {
  /*transform: translateY(0);*/
  box-shadow: 0 8px 16px rgba(15, 118, 110, 0.6);
}

.hint {
  font-size: 0.8rem;
  color: var(--muted);
}

.actions {
  margin-top: 8px;
  display: flex;
  justify-content: flex-start;
}

/* === RESULTS === */
.result-section {
  padding: 0;
}

.result-section h3 {
  margin: 0 0 8px;
  font-size: 0.95rem;
  color: var(--accent);
}

.result-section-heading {
  color: var(--accent);
  font-size: 1rem;
  font-weight: 500;
  margin: 20px 0 12px 0;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(171, 193, 213, 0.2);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  opacity: 0.9;
}

.result-section-heading:first-child {
  margin-top: 0;
}

/* Tables - shared styles */
/* Unified table: 3 columns (label, input, unit) - aligns all inputs */
.calc-unified-table {
  table-layout: fixed;
  width: auto;
  font-size: 0.85rem;
  border-collapse: collapse;
}

.calc-unified-table .col-label { width: 200px; min-width: 200px; }
.calc-unified-table .col-input { width: 110px; min-width: 110px; }
.calc-unified-table .col-unit { width: 80px; min-width: 80px; }

.calc-unified-table tr {
  border-bottom: 1px solid rgba(38, 43, 58, 0.3);
}

.calc-unified-table tr:last-child {
  border-bottom: none;
}

.calc-unified-table td {
  padding: 6px 0;
  line-height: 1.3;
  vertical-align: middle;
}

.calc-unified-table td:first-child {
  color: var(--muted);
  padding-right: 24px;
  font-size: 0.8rem;
  white-space: nowrap;
}

.calc-unified-table td:nth-child(2) {
  text-align: right;
}

.calc-unified-table td:nth-child(2):has(input[type="checkbox"]) {
  text-align: left;
}

.calc-unified-table input[type="checkbox"] {
  width: 16px;
  height: 16px;
  display: inline-block;
  margin: 0;
  cursor: pointer;
  accent-color: var(--accent);
  vertical-align: middle;
}

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

.calc-toolbar {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
}

.calc-toolbar .calc-subtabs {
  margin: 0;
}

.calc-unified-table td:nth-child(3) {
  color: var(--muted);
  font-size: 0.8rem;
  padding-left: 8px;
}

.calc-unified-table input {
  width: 100%;
  max-width: 100px;
  margin: 0;
  text-align: right;
  box-sizing: border-box;
}

.calc-unified-table select {
  width: 100%;
  max-width: 140px;
  margin: 0;
  box-sizing: border-box;
}

.calc-results-wrapper {
  align-self: flex-start;
}

.calc-results-heading {
  margin: 0 0 10px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Input table - same layout as result table */
.calc-input-table {
  width: auto;
  font-size: 0.85rem;
  margin-bottom: 20px;
  border-collapse: collapse;
}

.calc-input-table tr {
  border-bottom: 1px solid rgba(38, 43, 58, 0.3);
}

.calc-input-table tr:last-child {
  border-bottom: none;
}

.calc-input-table td {
  padding: 6px 0;
  line-height: 1.3;
  vertical-align: middle;
}

.calc-input-table td:first-child {
  color: var(--muted);
  padding-right: 24px;
  font-size: 0.8rem;
  white-space: nowrap;
}

.calc-input-table td:last-child {
  text-align: right;
}

.calc-input-table .input-with-unit {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  justify-content: flex-end;
  margin: 0;
}

.calc-input-table .input-with-unit input {
  width: 100px;
  min-width: 100px;
  max-width: 100px;
  margin: 0;
  text-align: right;
  box-sizing: border-box;
}

.calc-input-table .input-unit {
  font-size: 0.8rem;
  color: var(--muted);
  flex-shrink: 0;
}

.result-table,
.features-table {
  width: auto;
  font-size: 0.85rem;
  margin-bottom: 8px;
  border-collapse: collapse;
}

.result-table tr,
.features-table td {
  border-bottom: 1px solid rgba(38, 43, 58, 0.3);
}

.result-table tr:last-child,
.features-table tbody tr:last-child td {
  border-bottom: none;
}

.result-table td,
.features-table td {
  padding: 5px 0;
  line-height: 1.3;
}

.result-table td:first-child,
.features-table td:first-child {
  color: var(--muted);
  padding-right: 24px;
  font-size: 0.8rem;
}

.result-table td:last-child,
.features-table td:last-child {
  text-align: right;
  white-space: nowrap;
}

/* Features table specific */
.features-table tbody tr:hover {
  background: rgba(171, 193, 213, 0.05);
}

.features-table .feature-yes {
  color: #4ade80;
  font-size: 1rem;
}

.features-table .feature-no {
  color: #f87171;
  font-size: 1rem;
}

/* === SUMMARY === */
.summary-content {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Summary items - base styles */
.summary-item,
.summary-total,
.summary-savings {
  padding: 10px;
  border-radius: 8px;
}

.summary-item {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(31, 41, 55, 0.7);
}

.summary-total {
  padding: 12px;
  background: rgba(171, 193, 213, 0.1);
  border: 1px solid var(--accent);
}

.summary-savings {
  padding: 12px;
  background: rgba(74, 222, 128, 0.1);
  border: 3px solid #4ade80;
  margin-top: 8px;
}

/* Summary labels */
.summary-item-label,
.summary-total-label,
.summary-savings-label {
  color: var(--muted);
  margin-bottom: 4px;
}

.summary-item-label {
  font-size: 0.8rem;
}

.summary-total-label,
.summary-savings-label {
  font-size: 1rem;
  margin-bottom: 6px;
}

/* Summary values */
.summary-item-value {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.summary-total-value,
.summary-savings-value {
  font-size: 1.4rem;
  font-weight: 700;
}

.summary-total-value {
  color: var(--accent);
}

.summary-savings-value {
  color: #4ade80;
}

/* === FEATURES === */
.features-section {
  padding: 12px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(31, 41, 55, 0.7);
}

.features-section h3 {
  margin: 0 0 10px;
  font-size: 1rem;
  color: var(--accent);
}

/* === NEW CALCULATOR LAYOUT === */

.calculator-wrapper {
  background: linear-gradient(145deg, #111827, #020617);
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 0;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.55);
  overflow: hidden;
  margin-top: 20px;
}

/* --- Main Tabs --- */
.calc-main-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.4);
}

.calc-main-tab {
  flex: 1;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  border: none;
  border-bottom: 3px solid transparent;
  padding: 16px 8px;
  font-size: 0.95rem;
  box-shadow: none;
  transition: all 0.2s;
}

.calc-main-tab:hover {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  transform: none;
}

.calc-main-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  background: rgba(171, 193, 213, 0.05);
  font-weight: 700;
}

/* --- Content Panels --- */
.calc-tab-content {
  display: none;
  padding: 24px;
}

.calc-tab-content.active {
  display: block;
}

/* --- Flex-wrap input flow --- */
.calc-shared-row {
  margin-bottom: 16px;
}

.calc-shared-row .calc-input-flow {
  margin-bottom: 0;
}

.calc-toolbar {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  margin: 12px 0 20px;
}

.calc-toolbar .calc-checkbox-label {
  margin-left: 2px;
}

.calc-toolbar .calc-subtabs {
  margin: 0;
}

.calc-checkbox-row {
  display: flex;
  align-items: center;
}

.calc-input-result-row {
  display: flex;
  flex-wrap: wrap;
  gap: 32px;
  align-items: flex-start;
}

.calc-input-result-row .calc-input-table,
.calc-input-result-row .calc-unified-table {
  margin-bottom: 0;
}

.calc-input-result-row .result-table,
.calc-input-result-row .calc-results-wrapper .result-table {
  margin-bottom: 0;
}

.result-table-3col th,
.result-table-4col th {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent);
  text-align: right;
  padding: 0 0 6px 16px;
  white-space: nowrap;
}

.result-table-3col th:first-child,
.result-table-4col th:first-child {
  text-align: left;
  padding-left: 0;
  color: transparent;
}

.result-table-3col td:nth-child(2),
.result-table-3col td:nth-child(3),
.result-table-4col td:nth-child(2),
.result-table-4col td:nth-child(3),
.result-table-4col td:nth-child(4) {
  text-align: right;
  padding-left: 16px;
  white-space: nowrap;
}

.cost-winner { color: #4ade80; font-weight: 600; }
.cost-second  { color: #fb923c; font-weight: 600; }
.cost-loser   { color: #f87171; font-weight: 600; }

.calc-checkbox-label {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 4px;
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
  white-space: nowrap;
  cursor: pointer;
  flex-shrink: 0;
}

.calc-checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  margin-right: 6px;
  vertical-align: middle;
  align-self: center;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}

.calc-input-flow {
  display: flex;
  flex-wrap: wrap;
  gap: 24px 28px;
}

.calc-input-flow label {
  flex: 1 1 180px;
  min-width: 160px;
  white-space: nowrap;
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.calc-input-flow input,
.calc-input-flow select {
  margin-top: 6px;
  font-family: 'Inter', monospace;
  font-variant-numeric: tabular-nums;
}

.calc-input-flow .input-with-unit {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
}

.calc-input-flow .input-with-unit input {
  margin-top: 0;
  flex: 1;
  min-width: 0;
}

.calc-input-flow .input-unit {
  font-size: 0.8rem;
  color: var(--muted);
  flex-shrink: 0;
}

/* --- Unit Costs Section --- */
.calc-unit-costs {
  margin-bottom: 24px;
}

.unit-cost-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

.unit-cost-grid.four-col {
  grid-template-columns: repeat(4, 1fr);
}

.calc-unit-costs label {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.calc-unit-costs input {
  margin-top: 6px;
  background: rgba(0, 0, 0, 0.3);
  border-color: rgba(255, 255, 255, 0.1);
  font-family: 'Inter', monospace;
  font-variant-numeric: tabular-nums;
}

/* --- Split Layout --- */
.calc-divider {
  border: 0;
  height: 1px;
  background: rgba(255, 255, 255, 0.1);
  margin: 24px 0;
}

.calc-split-layout {
  display: flex;
  gap: 30px;
  position: relative;
}

.calc-column {
  flex: 1;
}

.calc-column-divider {
  width: 1px;
  background: rgba(255, 255, 255, 0.1);
  align-self: stretch;
}

.calc-column label {
  margin-top: 12px;
  font-weight: normal;
  color: var(--muted);
  font-size: 0.85rem;
}

.calc-column input {
  font-weight: 600;
  color: #fff;
}

.readonly-field {
  background: rgba(171, 193, 213, 0.1) !important;
  border-color: rgba(171, 193, 213, 0.3) !important;
  color: var(--accent) !important;
  cursor: default;
}

/* --- Footer Controls --- */
.calc-footer-controls {
  max-width: 400px;
  margin: 0 auto;
}

/* --- Header Radio Buttons --- */
.calc-column-header {
  display: flex;
  align-items: center;
}

.calc-column-header .section-radio {
  margin: 20px 0 12px 0 !important;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(171, 193, 213, 0.2);
  color: var(--accent);
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  opacity: 0.9;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  width: 100%;
}

.calc-column-header .section-radio:first-child {
  margin-top: 0;
}

.section-radio input[type="radio"] {
  width: 1.1em;
  height: 1.1em;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
  position: relative;
  top: -1px;
}

/* --- Sub-Tabs (pill toggle, reusable) --- */
.calc-subtabs {
  display: inline-flex;
  gap: 4px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 8px;
  padding: 3px;
  margin-bottom: 20px;
}

.calc-subtab {
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  padding: 7px 18px;
  font-size: 0.82rem;
  box-shadow: none;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  font-weight: 500;
  letter-spacing: 0.2px;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

.calc-subtab:hover,
.calc-subtab:focus,
.calc-subtab:focus-visible,
.calc-subtab:active {
  outline: none;
  box-shadow: none;
}

.calc-subtab:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.calc-subtab.active {
  color: #fff;
  background: rgba(171, 193, 213, 0.15);
  border-color: rgba(171, 193, 213, 0.3);
  font-weight: 600;
}

.calc-subtab-content {
  display: none;
  padding: 20px 0 0 0;
}

.calc-subtab-content.active {
  display: block;
}

/* --- Result badges --- */
.badge-yes {
  color: #4ade80;
  font-weight: 700;
}

.badge-no {
  color: #f87171;
  font-weight: 700;
}

/* --- Compressor Section --- */
.calc-compressor-section {
  margin: 0 0 20px 0;
}

.calc-compressor-controls {
  max-width: 400px;
}

/* --- Tweak Tab Hover --- */
.calc-main-tab:hover {
  background: rgba(255, 255, 255, 0.015); /* Reduced opacity */
  color: var(--text);
}

@media (max-width: 900px) {
  .unit-cost-grid.four-col {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .calc-shared-row {
    flex-direction: column;
    align-items: stretch;
  }

  .calc-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .calc-toolbar .calc-subtabs {
    justify-content: stretch;
  }

  .calc-input-result-row {
    flex-direction: column;
  }

  .calc-split-layout {
    flex-direction: column;
    gap: 20px;
  }
  
  .calc-column-divider {
    width: 100%;
    height: 1px;
    margin: 10px 0;
  }
  
  .calc-main-tabs {
    flex-direction: column;
  }
  
  .calc-main-tab {
    border-bottom: 1px solid var(--border);
    border-left: 3px solid transparent;
    text-align: left;
    padding-left: 20px;
  }
  
  .calc-main-tab.active {
    border-bottom: 1px solid var(--border);
    border-left-color: var(--accent);
  }

  .calc-subtabs {
    flex-wrap: wrap;
  }

  .calc-subtab {
    font-size: 0.78rem;
    padding: 6px 12px;
  }
}


/* === FOOTER === */
.page footer {
  margin-top: 18px;
  font-size: 0.8rem;
  color: var(--muted);
}

/* Mobile: 2 columns, 4 rows layout */
@media (max-width: 1200px) {
  .input-grid {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: auto auto auto auto;
    gap: 12px;
  }
  
  /* Reset grid positioning for mobile */
  .input-card,
  .result-card,
  .summary-card,
  .features-card {
    grid-row: auto;
  }
  
  /* Make cards stack properly in 2-column layout */
  .input-output-column:nth-child(1) .input-card {
    grid-column: 1;
    grid-row: 1;
  }
  
  .input-output-column:nth-child(1) .result-card {
    grid-column: 1;
    grid-row: 2;
  }
  
  .input-output-column:nth-child(2) .input-card {
    grid-column: 2;
    grid-row: 1;
  }
  
  .input-output-column:nth-child(2) .result-card {
    grid-column: 2;
    grid-row: 2;
  }
  
  .input-output-column:nth-child(3) .input-card {
    grid-column: 1;
    grid-row: 3;
  }
  
  .input-output-column:nth-child(3) .result-card {
    grid-column: 1;
    grid-row: 4;
  }
  
  .input-output-column:nth-child(4) .summary-card {
    grid-column: 2;
    grid-row: 3;
  }
  
  .input-output-column:nth-child(4) .features-card {
    grid-column: 2;
    grid-row: 4;
  }
  
  /* Reduce padding on mobile */
  .card,
  .result-card,
  .summary-card,
  .features-card {
    padding: 12px;
  }
  
  /* Smaller fonts on mobile */
  label {
    font-size: 0.8rem;
    margin-top: 12px;
  }
  
  input[type="text"],
  select {
    font-size: 0.85rem;
    padding: 5px 6px;
  }
  
  .result-section-heading {
    font-size: 0.9rem;
    margin: 16px 0 10px 0;
  }
}

@media (max-width: 768px) {
  .page {
    padding-inline: 12px;
  }

  header h1 {
    font-size: 1.5rem;
  }
  
  /* Single column on very small screens */
  .input-grid {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
  }
  
  /* Reset all grid positioning for single column */
  .input-output-column:nth-child(1) .input-card,
  .input-output-column:nth-child(1) .result-card,
  .input-output-column:nth-child(2) .input-card,
  .input-output-column:nth-child(2) .result-card,
  .input-output-column:nth-child(3) .input-card,
  .input-output-column:nth-child(3) .result-card,
  .input-output-column:nth-child(4) .summary-card,
  .input-output-column:nth-child(4) .features-card {
    grid-column: 1;
    grid-row: auto;
  }
}
