/* ============================================================
   Pasadena Pools — Equipment Layout Tool
   ============================================================ */

:root {
  --blue: #1a5276;
  --blue-light: #2980b9;
  --blue-pale: #d6eaf8;
  --orange: #e67e22;
  --green: #27ae60;
  --red: #c0392b;
  --gray: #7f8c8d;
  --gray-light: #ecf0f1;
  --gray-dark: #2c3e50;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f5f6fa;
  color: var(--gray-dark);
  overflow: hidden;
}

/* ── Header ─────────────────────────────────────────────── */
.header {
  background: var(--blue);
  color: #fff;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  height: 48px;
}
.header h1 { font-size: 18px; font-weight: 700; white-space: nowrap; }
.header .subtitle { font-size: 12px; opacity: .6; }
.header-actions { margin-left: auto; display: flex; gap: 8px; }
.header-btn {
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.25);
  color: #fff;
  padding: 5px 12px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  font-weight: 600;
}
.header-btn:hover { background: rgba(255,255,255,.25); }

/* ── App Layout ─────────────────────────────────────────── */
.app { display: flex; height: calc(100vh - 48px); }

/* ── Sidebar ────────────────────────────────────────────── */
.sidebar {
  width: 340px;
  min-width: 340px;
  background: #fff;
  border-right: 1px solid #ddd;
  overflow-y: auto;
  padding: 12px;
}

.section {
  margin-bottom: 10px;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  overflow: hidden;
}
.section-header {
  background: var(--blue);
  color: #fff;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.section-header:hover { background: var(--blue-light); }
.section-header .arrow { transition: transform .2s; font-size: 10px; }
.section-header.collapsed .arrow { transform: rotate(-90deg); }
.section-body { padding: 10px; }
.section-body.collapsed { display: none; }

/* ── Form elements ──────────────────────────────────────── */
label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--gray);
  margin-bottom: 3px;
  margin-top: 8px;
  text-transform: uppercase;
  letter-spacing: .4px;
}
label:first-child { margin-top: 0; }

input[type="number"], input[type="text"], select {
  width: 100%;
  padding: 5px 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 13px;
  background: #fff;
}
input:focus, select:focus {
  outline: none;
  border-color: var(--blue-light);
  box-shadow: 0 0 0 2px rgba(41,128,185,.12);
}
.row { display: flex; gap: 8px; }
.row > div { flex: 1; }
.hint { font-size: 10px; color: var(--gray); margin-top: 1px; }

/* ── Return line items ──────────────────────────────────── */
.return-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  border-bottom: 1px solid #f0f0f0;
}
.return-item:last-child { border-bottom: none; }
.return-item input[type="checkbox"] { width: auto; flex-shrink: 0; }
.return-item label {
  margin: 0;
  text-transform: none;
  font-weight: 500;
  color: var(--gray-dark);
  flex: 1;
  font-size: 12px;
}
.return-item input[type="number"] { width: 48px; text-align: center; }
.return-item .unit { font-size: 10px; color: var(--gray); min-width: 20px; }

/* ── Calculation info cards ─────────────────────────────── */
.calc-card {
  background: var(--blue-pale);
  border-radius: 5px;
  padding: 8px 10px;
  margin-top: 8px;
  font-size: 12px;
}
.calc-card h4 { font-size: 11px; color: var(--blue); margin-bottom: 4px; text-transform: uppercase; letter-spacing: .4px; }
.calc-row { display: flex; justify-content: space-between; padding: 1px 0; }
.calc-row .val { font-weight: 700; color: var(--blue); }
.calc-row.warn .val { color: var(--red); }
.calc-row.ok .val { color: var(--green); }

/* ── Buttons ────────────────────────────────────────────── */
.btn-generate {
  width: 100%;
  padding: 9px;
  background: var(--orange);
  color: #fff;
  border: none;
  border-radius: 5px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 10px;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.btn-generate:hover { background: #d35400; }

.btn-save {
  width: 100%;
  padding: 7px;
  background: var(--green);
  color: #fff;
  border: none;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 6px;
}
.btn-save:hover { background: #219a52; }

.btn-secondary {
  padding: 5px 10px;
  background: var(--gray-light);
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 11px;
  cursor: pointer;
  color: var(--gray-dark);
}
.btn-secondary:hover { background: #ddd; }

/* ── Main content area ──────────────────────────────────── */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

/* Tabs */
.tabs {
  display: flex;
  background: #fff;
  border-bottom: 1px solid #ddd;
  padding: 0 16px;
  flex-shrink: 0;
}
.tab {
  padding: 9px 18px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  color: var(--gray);
  border-bottom: 2px solid transparent;
  transition: all .15s;
  text-transform: uppercase;
  letter-spacing: .3px;
}
.tab:hover { color: var(--blue); }
.tab.active { color: var(--blue); border-bottom-color: var(--blue); }

.tab-content { flex: 1; overflow: auto; background: #f5f6fa; padding: 12px; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* SVG container */
.svg-wrap {
  background: #fff;
  border-radius: 6px;
  border: 1px solid #ddd;
  min-height: 480px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
}
.svg-wrap svg { width: 100%; height: auto; min-width: 900px; }

.placeholder-msg {
  color: #bbb;
  text-align: center;
  padding: 40px;
}
.placeholder-msg b { color: var(--orange); }

/* Legend */
.legend {
  display: flex;
  gap: 14px;
  padding: 6px 12px;
  background: #fff;
  border-radius: 5px;
  border: 1px solid #ddd;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.legend-item { display: flex; align-items: center; gap: 5px; font-size: 11px; color: #555; }
.legend-swatch { width: 20px; height: 3px; border-radius: 2px; }

/* ── Save/Load Modal ────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal {
  background: #fff;
  border-radius: 10px;
  width: 500px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.modal-header {
  padding: 14px 18px;
  border-bottom: 1px solid #eee;
  font-weight: 700;
  color: var(--blue);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: #999;
  padding: 0 4px;
}
.modal-close:hover { color: #333; }
.modal-body { padding: 16px 18px; }

/* Layout list */
.layout-list { list-style: none; }
.layout-item {
  padding: 10px 12px;
  border: 1px solid #eee;
  border-radius: 6px;
  margin-bottom: 6px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.layout-item:hover { border-color: var(--blue-light); background: #f8f9ff; }
.layout-item .name { font-weight: 600; font-size: 13px; }
.layout-item .meta { font-size: 11px; color: #999; }
.layout-item .actions { display: flex; gap: 4px; }

/* ── Print styles ───────────────────────────────────────── */
@media print {
  .sidebar, .tabs, .header-actions { display: none; }
  .app { display: block; }
  .main { overflow: visible; }
  .tab-panel { display: block !important; page-break-after: always; }
}
