/* AlarmStream — Main Stylesheet */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary:   #1a3a5c;
  --accent:    #2563eb;
  --accent2:   #dc2626;
  --success:   #16a34a;
  --warn:      #ca8a04;
  --bg:        #f1f5f9;
  --card:      #ffffff;
  --border:    #e2e8f0;
  --text:      #1e293b;
  --muted:     #64748b;
  --radius:    8px;
  --shadow:    0 2px 12px rgba(0,0,0,0.08);
}

body { font-family: 'Segoe UI', Arial, sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }

/* ── Header ── */
header {
  background: var(--primary);
  color: white;
  padding: 0 32px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.logo { font-size: 22px; font-weight: 800; letter-spacing: -0.5px; }
.logo span { color: #60a5fa; }
.header-sub { font-size: 11px; color: #93c5fd; margin-top: 2px; }
nav { display: flex; gap: 6px; }
nav button {
  background: transparent; border: 1px solid rgba(255,255,255,0.2);
  color: white; padding: 6px 14px; border-radius: 6px;
  cursor: pointer; font-size: 13px; transition: all .15s;
}
nav button:hover, nav button.active { background: rgba(255,255,255,0.15); }

/* ── Layout ── */
main { max-width: 1100px; margin: 0 auto; padding: 28px 20px; }

/* ── Cards ── */
.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 28px; margin-bottom: 24px;
}
.card-title {
  font-size: 17px; font-weight: 700; color: var(--primary);
  margin-bottom: 20px; padding-bottom: 12px; border-bottom: 2px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.card-title .icon { font-size: 20px; }

/* ── Step Progress ── */
.steps {
  display: flex; align-items: center; margin-bottom: 28px; gap: 0;
}
.step {
  display: flex; flex-direction: column; align-items: center;
  flex: 1; position: relative;
}
.step:not(:last-child)::after {
  content: ''; position: absolute; top: 20px; left: 50%; width: 100%;
  height: 2px; background: var(--border); z-index: 0;
}
.step.done:not(:last-child)::after { background: var(--accent); }
.step-num {
  width: 40px; height: 40px; border-radius: 50%;
  border: 2px solid var(--border); background: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; color: var(--muted);
  position: relative; z-index: 1;
}
.step.active .step-num { border-color: var(--accent); color: var(--accent); background: #eff6ff; }
.step.done .step-num { border-color: var(--accent); background: var(--accent); color: white; }
.step-label { font-size: 11px; color: var(--muted); margin-top: 6px; text-align: center; }
.step.active .step-label { color: var(--accent); font-weight: 600; }

/* ── Forms ── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 18px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1/-1; }
label { font-size: 13px; font-weight: 600; color: var(--text); }
label .req { color: var(--accent2); }
input, select, textarea {
  padding: 9px 12px; border: 1px solid var(--border); border-radius: 6px;
  font-size: 14px; color: var(--text); background: white;
  transition: border-color .15s;
}
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px #dbeafe; }
.hint { font-size: 11px; color: var(--muted); }
.input-prefix { position: relative; }
.input-prefix span {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  color: var(--muted); font-size: 14px;
}
.input-prefix input { padding-left: 24px; }

/* ── Toggle Switch ── */
.toggle-row { display: flex; align-items: center; gap: 10px; }
.toggle { position: relative; display: inline-block; width: 44px; height: 24px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; cursor: pointer; inset: 0;
  background: #cbd5e1; border-radius: 24px; transition: .2s;
}
.slider::before {
  content: ''; position: absolute;
  width: 18px; height: 18px; left: 3px; bottom: 3px;
  background: white; border-radius: 50%; transition: .2s;
}
input:checked + .slider { background: var(--accent); }
input:checked + .slider::before { transform: translateX(20px); }

/* ── Buttons ── */
.btn {
  padding: 10px 22px; border-radius: 6px; font-size: 14px; font-weight: 600;
  cursor: pointer; border: none; transition: all .15s;
}
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: #1d4ed8; }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #15803d; }
.btn-outline { background: white; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { background: var(--bg); }
.btn-danger { background: var(--accent2); color: white; }
.btn-row { display: flex; gap: 12px; justify-content: flex-end; margin-top: 24px; }

/* ── Tabs ── */
.tabs { display: flex; border-bottom: 2px solid var(--border); margin-bottom: 20px; }
.tab-btn {
  padding: 10px 20px; border: none; background: none; cursor: pointer;
  font-size: 14px; color: var(--muted); border-bottom: 2px solid transparent;
  margin-bottom: -2px; transition: all .15s;
}
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ── Tables ── */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { background: var(--primary); color: white; padding: 10px 12px; text-align: left; font-size: 12px; }
td { padding: 9px 12px; border-bottom: 1px solid var(--border); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8fafc; }
.td-num { text-align: right; font-variant-numeric: tabular-nums; }
.td-total { font-weight: 700; }
tfoot td { font-weight: 700; background: #f1f5f9; }

/* ── Summary Boxes ── */
.summary-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 24px; }
.summary-box {
  background: white; border: 1px solid var(--border); border-radius: 8px;
  padding: 16px; text-align: center;
}
.summary-box .val { font-size: 26px; font-weight: 800; color: var(--accent); }
.summary-box .lbl { font-size: 11px; color: var(--muted); margin-top: 4px; }

/* ── Price Total ── */
.price-total {
  background: var(--primary); color: white; border-radius: 8px;
  padding: 20px 28px; display: flex; justify-content: space-between; align-items: center;
}
.price-total .label { font-size: 14px; color: #93c5fd; }
.price-total .amount { font-size: 32px; font-weight: 800; }

/* ── SVG Riser Container ── */
.riser-container { border: 1px solid var(--border); border-radius: 8px; overflow: auto; background: #f8fafc; }
.riser-container svg { width: 100%; height: auto; }

/* ── Device Schedule ── */
.schedule-section { margin-bottom: 20px; }
.schedule-section h4 { font-size: 13px; font-weight: 700; color: var(--primary); margin-bottom: 10px; padding: 6px 10px; background: #eff6ff; border-radius: 4px; }
.nfpa-ref { font-size: 10px; color: #7c3aed; font-weight: 600; }

/* ── Alert / Info Boxes ── */
.info-box { background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 6px; padding: 12px 16px; font-size: 13px; color: #1e40af; margin-bottom: 16px; }
.warn-box { background: #fffbeb; border: 1px solid #fde68a; border-radius: 6px; padding: 12px 16px; font-size: 13px; color: #92400e; margin-bottom: 16px; }

/* ── Page Sections ── */
.page { display: none; }
.page.active { display: block; }

/* ── Price List Setup ── */
.price-category { margin-bottom: 20px; }
.price-category h4 { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 12px; }

/* ── Print ── */
/* ── Floor Plan Module ── */
.fp-toolbar { display:flex; flex-direction:column; }
.fp-device-btn {
  display:flex; align-items:center; gap:8px;
  width:100%; padding:8px 10px; margin-bottom:6px;
  border-radius:6px; border:2px solid transparent;
  cursor:pointer; font-size:12px; font-weight:600;
  background:white; transition:all .12s;
}
.fp-device-btn:hover  { background:#f1f5f9; }
.fp-device-btn.active { border-color:var(--accent); background:#eff6ff; }
.fp-device-dot { width:10px;height:10px;border-radius:50%;flex-shrink:0; }
.fp-auto-btn {
  display:block; width:100%; padding:6px 8px; margin-bottom:5px;
  border-radius:5px; border:1px solid var(--border);
  background:white; cursor:pointer; font-size:11px; font-weight:600;
  text-align:left; transition:all .12s;
}
.fp-auto-btn:hover { background:#f1f5f9; }
.fp-mode-btn {
  display:block; width:100%; padding:7px 10px; margin-bottom:5px;
  border-radius:5px; cursor:pointer; font-size:12px; font-weight:600;
  border:none; transition:all .12s;
}
.fp-count-row {
  display:flex; align-items:center; gap:6px;
  padding:5px 0; border-bottom:1px solid var(--border);
  font-size:12px;
}
.fp-count-row:last-child { border-bottom:none; }
.fp-count-dot  { width:8px;height:8px;border-radius:50%;flex-shrink:0; }
.fp-count-label{ flex:1; color:var(--text); }
.fp-count-num  { font-weight:700; font-variant-numeric:tabular-nums; }
.fp-count-icon { width:16px;text-align:center;font-size:13px; }
.fp-count-row.ok      .fp-count-icon { color:var(--success); }
.fp-count-row.partial .fp-count-icon { color:var(--warn); }
.fp-legend-row { display:flex;align-items:center;gap:7px;font-size:11px;margin-bottom:5px; }

/* ── Spec PDF Import Bar ── */
.spec-import-bar {
  display: flex; align-items: center; gap: 16px;
  background: linear-gradient(135deg, #eff6ff 0%, #f0fdf4 100%);
  border: 1.5px solid var(--accent);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 22px;
}
.spec-import-left  { display:flex; align-items:flex-start; gap:12px; flex:1; }
.spec-import-icon  { font-size:28px; line-height:1; }
.spec-import-title { font-size:14px; font-weight:700; color:var(--primary); margin-bottom:3px; }
.spec-import-sub   { font-size:12px; color:var(--muted); line-height:1.4; }
.spec-import-btn   { white-space:nowrap; flex-shrink:0; }

/* ── Spec Modal ── */
.spec-modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.55);
  z-index: 2000; display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.spec-modal {
  background: var(--card); border-radius: 12px; box-shadow: 0 8px 40px rgba(0,0,0,0.22);
  width: 100%; max-width: 740px; max-height: 90vh; overflow-y: auto;
  display: flex; flex-direction: column;
}
.spec-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px 14px; border-bottom: 1px solid var(--border);
}
.spec-modal-title  { font-size:16px; font-weight:700; color:var(--primary); }
.spec-modal-close  { background:none; border:none; font-size:22px; cursor:pointer; color:var(--muted); padding:0 4px; }
.spec-modal-close:hover { color:var(--accent2); }

.spec-modal-footer {
  padding: 16px 24px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px;
}

/* Progress */
.spec-progress-label { font-size:13px; color:var(--muted); padding: 20px 24px 8px; }
.spec-progress-bar   { height:8px; background:#e2e8f0; border-radius:4px; margin:0 24px 24px; overflow:hidden; }
.spec-progress-fill  { height:100%; background:var(--accent); border-radius:4px; width:0%; transition:width 0.3s ease; }

/* Results meta */
.spec-results-meta {
  font-size:12px; color:var(--muted); padding: 12px 24px 0;
  border-bottom: 1px solid var(--border); padding-bottom: 12px;
  margin-bottom: 4px;
}

/* Results grid */
.spec-results-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0;
  padding: 4px 24px 12px;
}
.spec-field-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 0; border-bottom: 1px solid #f1f5f9;
}
.spec-field-row:nth-child(odd)  { padding-right: 16px; }
.spec-field-row:nth-child(even) { padding-left:  16px; border-left: 1px solid var(--border); }
.spec-field-badge {
  display: inline-block; padding: 1px 7px; border-radius: 10px;
  font-size: 10px; font-weight: 700; letter-spacing: 0.3px; flex-shrink: 0;
}
.spec-badge-high   { background:#dcfce7; color:#15803d; }
.spec-badge-medium { background:#fef9c3; color:#92400e; }
.spec-badge-low    { background:#fee2e2; color:#991b1b; }
.spec-field-label  { font-size:12px; color:var(--muted); flex:1; }
.spec-field-value  { font-size:14px; font-weight:700; color:var(--text); white-space:nowrap; }
.spec-field-edit   {
  border: 1px solid var(--border); border-radius:4px; padding:3px 6px;
  font-size:13px; width:100px; font-weight:600; color:var(--text);
}

/* Warnings */
.spec-warnings {
  margin: 0 24px 12px; padding: 10px 14px;
  background: #fffbeb; border: 1px solid #fcd34d; border-radius:6px;
  font-size:12px; color:#92400e; line-height:1.7;
}
.spec-warnings:empty { display:none; }

/* Raw text toggle */
.spec-raw-toggle { padding: 0 24px 16px; }
.btn-link { background:none; border:none; color:var(--accent); cursor:pointer; font-size:12px; padding:0; }
.btn-link:hover { text-decoration:underline; }
#spec-raw-text {
  background:#f8fafc; border:1px solid var(--border); border-radius:6px;
  padding:10px; font-size:11px; white-space:pre-wrap; word-break:break-word;
  max-height:200px; overflow-y:auto; margin-top:8px; color:var(--muted);
}

/* Disabled button state for spec modal */
.spec-modal-footer .btn-primary:disabled {
  opacity: 0.4; cursor: not-allowed;
}

/* highlight fields that were auto-filled */
.spec-filled {
  border-color: var(--accent) !important;
  background: #eff6ff !important;
  transition: background 1.2s ease;
}

@media print {
  header, nav, .btn-row, .steps, .tabs { display: none !important; }
  body { background: white; }
  .card { box-shadow: none; border: 1px solid #ddd; }
}

@media (max-width: 700px) {
  .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
  .summary-grid { grid-template-columns: 1fr 1fr; }
}
