/* FireCalc Tools - Shared Styles */

body {
  padding: 0;
  background: var(--bg);
}

/* Layout */
.tool-layout {
  display: flex;
  min-height: calc(100vh - 64px);
  margin-top: 64px; /* Account for fixed header */
}

.tool-sidebar {
  width: 220px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 20px 0;
  flex-shrink: 0;
}

.tool-sidebar .nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
}

.tool-sidebar .nav-item:hover {
  background: var(--bg);
  color: var(--text);
}

.tool-sidebar .nav-item.active {
  background: rgba(0, 51, 102, 0.08);
  color: var(--primary);
  border-right: 3px solid var(--primary);
}

.tool-sidebar .nav-divider {
  height: 1px;
  background: var(--border);
  margin: 16px 20px;
}

.tool-main {
  flex: 1;
  padding: 32px;
  max-width: 900px;
}

/* Header */
.tool-header {
  margin-bottom: 28px;
}

.tool-header h1 {
  text-align: left;
  margin: 0 0 8px;
  font-size: 28px;
}

.tool-header .subtitle {
  color: var(--muted);
  font-size: 15px;
}

/* Calculator Cards */
.calc-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 20px;
}

.calc-card h2 {
  font-size: 18px;
  margin: 0 0 20px;
  color: var(--primary);
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.calc-card h3 {
  font-size: 15px;
  margin: 20px 0 12px;
  color: var(--text);
}

/* Form Elements */
.input-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
}

.form-group label {
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text);
}

.input-with-unit {
  display: flex;
  align-items: stretch;
  gap: 0;
  width: 100%;
}

.input-with-unit input[type="number"] {
  flex: 1 1 auto !important;
  min-width: 80px !important;
  width: 100% !important;
  border-radius: 8px 0 0 8px;
  border-right: none;
  padding: 10px 12px;
  font-size: 15px;
  border: 1px solid var(--border);
  box-sizing: border-box;
}

.input-with-unit .unit-label {
  flex: 0 0 auto;
  background: var(--bg);
  border: 1px solid var(--border);
  border-left: none;
  border-radius: 0 8px 8px 0;
  padding: 10px 12px;
  font-size: 14px;
  color: var(--muted);
  white-space: nowrap;
}

.input-with-unit .unit-select,
.input-with-unit select {
  flex: 0 0 auto !important;
  background: var(--bg);
  border: 1px solid var(--border);
  border-left: none;
  border-radius: 0 8px 8px 0;
  padding: 10px 12px;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
  width: auto !important;
  min-width: 70px;
  max-width: 100px;
}

.helper-text {
  font-size: 13px;
  color: var(--muted);
  margin-top: 4px;
  margin-bottom: 12px;
}

.calculated-value {
  padding: 10px 12px;
  background: #e0f2fe;
  border: 1px solid #7dd3fc;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  color: #0369a1;
}

.method-inputs {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.divider {
  height: 1px;
  background: var(--border);
  margin: 20px 0;
}

/* Info Icons & Tooltips */
.info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 50%;
  font-size: 11px;
  color: var(--muted);
  cursor: pointer;
  margin-left: 6px;
  vertical-align: middle;
  font-weight: 600;
}

.info-icon:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.tooltip {
  display: none;
  position: absolute;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  font-size: 13px;
  max-width: 280px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 100;
  line-height: 1.5;
}

/* Results */
.result-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  margin-top: 20px;
}

.result-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.result-label {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 4px;
}

.result-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--primary);
}

.result-secondary {
  font-size: 14px;
  color: var(--text);
  margin-top: 12px;
}

.result-breakdown {
  font-size: 13px;
  color: var(--muted);
  margin-top: 12px;
  line-height: 1.8;
}

/* Pills / Badges */
.pill {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 13px;
  background: var(--bg);
  color: var(--muted);
  border: 1px solid var(--border);
}

.pill.pass {
  background: rgba(16, 185, 129, 0.12);
  color: #059669;
  border-color: rgba(16, 185, 129, 0.3);
}

.pill.fail {
  background: rgba(239, 68, 68, 0.12);
  color: #dc2626;
  border-color: rgba(239, 68, 68, 0.3);
}

/* Formula Note */
.formula-note {
  font-size: 13px;
  color: var(--muted);
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* Warnings */
.warning-box {
  background: #fef3c7;
  border: 1px solid #f59e0b;
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 14px;
  color: #92400e;
  margin: 16px 0;
}

/* Action Row */
.action-row {
  display: flex;
  gap: 12px;
  margin-top: 20px;
  flex-wrap: wrap;
  align-items: center;
}

.copy-hint {
  font-size: 13px;
  color: var(--success);
  margin-left: 4px;
}

/* Reference Tables */
.ref-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  table-layout: fixed;
}

.ref-table th,
.ref-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.ref-table th:first-child,
.ref-table td:first-child {
  width: 60%;
}

.ref-table th:nth-child(2),
.ref-table td:nth-child(2) {
  width: 20%;
}

.ref-table th:nth-child(3),
.ref-table td:nth-child(3) {
  width: 20%;
}

.ref-table th {
  font-weight: 600;
  background: var(--bg);
  font-size: 13px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.ref-table tbody tr:hover {
  background: var(--bg);
}

/* Responsive */
@media (max-width: 768px) {
  .tool-layout {
    flex-direction: column;
  }

  .tool-sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 12px 0;
    display: flex;
    overflow-x: auto;
  }

  .tool-sidebar .nav-item {
    display: inline-flex;
    padding: 10px 16px;
    white-space: nowrap;
  }

  .tool-sidebar .nav-item.active {
    border-right: none;
    border-bottom: 3px solid var(--primary);
    background: transparent;
  }

  .tool-sidebar .nav-divider {
    display: none;
  }

  .tool-main {
    padding: 20px 16px;
  }

  .input-row {
    grid-template-columns: 1fr;
  }

  .result-row {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .tool-header h1 {
    font-size: 24px;
  }
}

@media (max-width: 480px) {
  .action-row {
    flex-direction: column;
  }

  .action-row .btn {
    width: 100%;
  }
}

/* Zone Rows (for flow test) */
.zone-row {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 12px;
}

.zone-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.zone-label {
  font-weight: 600;
  font-size: 14px;
  color: var(--primary);
}

.zone-remove {
  background: none;
  border: none;
  font-size: 20px;
  color: var(--muted);
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.zone-remove:hover {
  color: var(--danger);
}

.zone-row .input-row {
  margin-bottom: 0;
  align-items: end;
}

.zone-result {
  min-width: 80px;
}

.zone-result label {
  text-align: center;
}

.zone-result .pill {
  display: block;
  text-align: center;
}

/* Results Breakdown */
.results-breakdown {
  margin: 16px 0;
  padding: 12px;
  background: var(--bg);
  border-radius: 6px;
}

.breakdown-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 14px;
}

.breakdown-row:not(:last-child) {
  border-bottom: 1px solid var(--border);
}

.breakdown-label {
  color: var(--muted);
}

.breakdown-value {
  font-weight: 500;
}

/* Large pill */
.pill-large {
  font-size: 18px;
  padding: 8px 20px;
}

/* Graph Container */
.graph-container {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 12px;
}

.graph-container canvas {
  width: 100%;
  height: 350px;
  display: block;
}

.graph-legend {
  display: flex;
  gap: 20px;
  justify-content: center;
  flex-wrap: wrap;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

.legend-color {
  width: 14px;
  height: 14px;
  border-radius: 3px;
}

/* Zone responsive */
@media (max-width: 768px) {
  .zone-row .input-row {
    grid-template-columns: 1fr 1fr;
  }
  
  .zone-result {
    grid-column: span 2;
    text-align: center;
  }
}

@media (max-width: 480px) {
  .zone-row .input-row {
    grid-template-columns: 1fr;
  }
  
  .zone-result {
    grid-column: span 1;
  }
}

/* Outlet Rows (for multi-outlet flow test) */
.outlet-row {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 12px;
}

.outlet-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.outlet-label {
  font-weight: 600;
  font-size: 14px;
  color: var(--primary);
}

.outlet-remove {
  background: none;
  border: none;
  font-size: 20px;
  color: var(--muted);
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.outlet-remove:hover {
  color: var(--danger);
}

.outlet-inputs {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
}

.outlet-flow-result .calculated-value {
  font-size: 14px;
  padding: 8px 10px;
}

.total-flow-box {
  margin-top: 20px;
  padding: 16px;
  background: #e0f2fe;
  border: 1px solid #7dd3fc;
  border-radius: 8px;
  text-align: center;
}

.total-flow-label {
  font-size: 13px;
  color: #0369a1;
  margin-bottom: 4px;
}

.total-flow-value {
  font-size: 24px;
  font-weight: 700;
  color: #0369a1;
}

/* Nozzle Preset Selector */
.input-with-preset {
  display: flex;
  gap: 8px;
}

.input-with-preset input {
  flex: 1;
  min-width: 80px;
  padding: 10px 12px;
  font-size: 15px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.input-with-preset select.nozzle-preset {
  flex: 0 0 auto;
  padding: 8px 10px;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  cursor: pointer;
}

/* Cd Reference Popup */
.form-group {
  position: relative;
}

.cd-reference-popup,
.kit-reference-popup,
.nozzle-reference-popup {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  padding: 12px;
  z-index: 100;
}

.cd-reference-popup {
  width: 220px;
}

.kit-reference-popup {
  width: 280px;
  max-height: 400px;
  overflow-y: auto;
}

.nozzle-reference-popup {
  width: 180px;
}

.cd-popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.cd-popup-header strong {
  font-size: 13px;
}

.cd-popup-close {
  background: none;
  border: none;
  font-size: 18px;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.cd-popup-close:hover {
  color: var(--text);
}

.cd-popup-subtitle {
  font-size: 11px;
  color: var(--muted);
  margin: 0 0 10px;
}

.cd-ref-table {
  width: 100%;
  font-size: 13px;
  border-collapse: collapse;
}

.cd-ref-table th {
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-weight: 500;
}

.cd-ref-table td {
  padding: 8px;
  border-bottom: 1px solid var(--border);
}

.cd-ref-table tbody tr {
  cursor: pointer;
}

.cd-ref-table tbody tr:hover {
  background: rgba(0, 51, 102, 0.08);
}

.cd-popup-hint {
  font-size: 11px;
  color: var(--muted);
  margin: 10px 0 0;
}

/* Standard note */
.nozzle-standard-note {
  font-size: 12px;
  color: #059669;
  background: rgba(16, 185, 129, 0.1);
  padding: 8px 12px;
  border-radius: 6px;
  margin-top: 12px;
}
