/* breezeway-calls — dark theme, mobile-first */

:root {
  --bg: #0f1117;
  --bg-card: #1a1d27;
  --bg-input: #252836;
  --border: #2a2d3a;
  --text: #e4e6ed;
  --text-muted: #8b8fa3;
  --text-note: #d4a843;
  --accent: #4a7dff;
  --accent-hover: #5e8eff;
  --branch-bg: #252a3a;
  --branch-hover: #2f3548;
  --branch-border: #3a4058;
  --green: #3ddc84;
  --red: #ff5252;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --mono: 'SF Mono', 'Fira Code', monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-text-size-adjust: 100%;
}

/* ── PIN GATE ── */

#pin-gate {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; min-height: 100vh; padding: 2rem;
}
#pin-gate h1 { font-size: 1.2rem; font-weight: 500; margin-bottom: 1.5rem; color: var(--text-muted); }
#pin-input {
  background: var(--bg-input); border: 1px solid var(--border); color: var(--text);
  font-size: 1.5rem; text-align: center; padding: 0.75rem 1.5rem;
  border-radius: 8px; width: 200px; letter-spacing: 0.3em; outline: none;
}
#pin-input:focus { border-color: var(--accent); }
#pin-error { color: var(--red); margin-top: 0.75rem; font-size: 0.85rem; min-height: 1.2em; }

/* ── SEARCH VIEW ── */

#search-view { max-width: 600px; margin: 0 auto; padding: 1.5rem 1rem; }
#search-header { margin-bottom: 1.5rem; }
#search-header h1 { font-size: 1.1rem; font-weight: 600; color: var(--text-muted); margin-bottom: 1rem; }
#search-input {
  width: 100%; background: var(--bg-input); border: 1px solid var(--border);
  color: var(--text); font-size: 1rem; padding: 0.75rem 1rem; border-radius: 8px; outline: none;
}
#search-input:focus { border-color: var(--accent); }
#search-input::placeholder { color: var(--text-muted); }

.company-group { margin-bottom: 1.5rem; }
.company-group-name {
  font-size: 0.8rem; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.05em; padding: 0 0.25rem; margin-bottom: 0.5rem;
}
.lead-card {
  display: block; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 8px; padding: 0.85rem 1rem; margin-bottom: 0.5rem;
  color: var(--text); cursor: pointer; transition: border-color 0.1s;
}
.lead-card:hover, .lead-card:active { border-color: var(--accent); }
.lead-card.selected { border-color: var(--accent); background: rgba(74, 125, 255, 0.08); }
.lead-card.selected .lead-card-name::before { content: '\2713 '; color: var(--accent); }
.lead-card-name { font-weight: 600; font-size: 0.95rem; }
.lead-card-meta { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.2rem; }
.no-results { text-align: center; color: var(--text-muted); padding: 3rem 0; font-size: 0.9rem; }

/* ── LEAD VIEW ── */

#lead-view { max-width: 600px; margin: 0 auto; padding: 0 0 3rem; }

.lead-header {
  padding: 1rem 1rem 0.75rem; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--bg); z-index: 10;
}
.lead-header-top { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.4rem; }
.back-btn {
  background: none; border: none; color: var(--accent);
  font-size: 1.1rem; cursor: pointer; padding: 0.25rem; flex-shrink: 0;
}
.lead-name { font-size: 1.05rem; font-weight: 700; flex: 1; }
.lead-title { font-size: 0.8rem; color: var(--text-muted); padding-left: 2.1rem; }
.lead-phone {
  display: inline-block; margin-top: 0.35rem; padding-left: 2.1rem;
  font-size: 0.85rem; color: var(--accent); text-decoration: none;
}
.lead-phone:active { color: var(--accent-hover); }

/* Edit button */
.edit-btn {
  background: none; border: 1px solid var(--border); color: var(--text-muted);
  font-size: 0.8rem; padding: 0.3rem 0.75rem; border-radius: 6px;
  cursor: pointer; flex-shrink: 0; transition: border-color 0.1s, color 0.1s;
}
.edit-btn:hover { border-color: var(--accent); color: var(--accent); }
.edit-btn.active { border-color: var(--red); color: var(--red); }

/* Context panel */
.context-panel {
  margin: 0.75rem 1rem; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: 8px; overflow: hidden;
}
.context-toggle {
  display: flex; align-items: center; gap: 0.5rem; width: 100%;
  padding: 0.65rem 0.85rem; background: none; border: none;
  color: var(--text-muted); font-size: 0.8rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.04em; cursor: pointer; text-align: left;
}
.context-toggle .arrow { transition: transform 0.15s; font-size: 0.7rem; }
.context-panel.open .context-toggle .arrow { transform: rotate(90deg); }
.context-body {
  display: none; padding: 0 0.85rem 0.75rem; font-size: 0.85rem;
  line-height: 1.5; color: var(--text); white-space: pre-wrap; outline: none; border-radius: 4px;
}
.context-body.editable { background: rgba(74, 125, 255, 0.04); border: 1px dashed rgba(74, 125, 255, 0.2); }
.context-body:focus { background: rgba(74, 125, 255, 0.06); }
.context-panel.open .context-body { display: block; }

/* Breadcrumb */
.breadcrumb {
  display: flex; flex-wrap: wrap; gap: 0.25rem; align-items: center;
  padding: 0.6rem 1rem; font-size: 0.7rem; color: var(--text-muted); min-height: 2rem;
}
.breadcrumb-item {
  background: none; border: none; color: var(--text-muted);
  font-size: 0.7rem; cursor: pointer; padding: 0.15rem 0.3rem; border-radius: 3px;
}
.breadcrumb-item:hover { color: var(--accent); }
.breadcrumb-item.current { color: var(--text); font-weight: 600; cursor: default; }
.breadcrumb-sep { color: var(--text-muted); opacity: 0.5; }

/* Node */
.node { padding: 0 1rem; }

.node-label {
  font-size: 0.75rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--accent); margin-bottom: 0.75rem;
  outline: none; border-radius: 3px; padding: 0.1rem 0.2rem; margin-left: -0.2rem;
}
.node-label[contenteditable="true"]:focus { background: rgba(74, 125, 255, 0.1); }

.node-say {
  font-size: 1.1rem; line-height: 1.55; color: var(--text);
  white-space: pre-wrap; margin-bottom: 0.85rem;
  outline: none; border-radius: 4px; padding: 0.2rem 0.3rem; margin-left: -0.3rem;
}
.node-say[contenteditable="true"]:focus { background: rgba(74, 125, 255, 0.04); }

.node-note {
  font-size: 0.8rem; line-height: 1.45; color: var(--text-note);
  padding: 0.55rem 0.75rem; background: rgba(212, 168, 67, 0.08);
  border-left: 2px solid var(--text-note); border-radius: 0 6px 6px 0;
  margin-bottom: 1.25rem; white-space: pre-wrap; outline: none; min-height: 1.8em;
}
.node-note[contenteditable="true"]:focus { background: rgba(212, 168, 67, 0.12); }
.node-note:empty::before {
  content: attr(data-placeholder); color: rgba(212, 168, 67, 0.35); pointer-events: none;
}

/* Branches — view mode */
.branches { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 1.5rem; }

.branch-btn {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; background: var(--branch-bg); border: 1px solid var(--branch-border);
  border-radius: 8px; color: var(--text); font-size: 0.9rem;
  padding: 0.85rem 1rem; cursor: pointer; text-align: left;
  min-height: 48px; line-height: 1.3;
}
.branch-btn:hover { background: var(--branch-hover); border-color: var(--accent); }
.branch-btn:active { background: var(--branch-hover); }
.branch-arrow { color: var(--text-muted); margin-left: 0.5rem; flex-shrink: 0; }

/* Branches — edit mode */
.branch-row { display: flex; align-items: stretch; gap: 0; }
.branch-row .branch-btn { flex: 1; border-radius: 8px 0 0 8px; }

.branch-del {
  display: flex; align-items: center; justify-content: center; width: 32px;
  background: var(--branch-bg); border: 1px solid var(--branch-border); border-left: none;
  border-radius: 0 8px 8px 0; color: var(--text-muted); font-size: 1.1rem;
  cursor: pointer; opacity: 0.3; transition: opacity 0.1s, color 0.1s;
}
.branch-row:hover .branch-del { opacity: 1; }
.branch-del:hover { color: var(--red); background: rgba(255, 82, 82, 0.08); }

.branch-label-edit {
  outline: none; border-radius: 3px; padding: 0.05rem 0.15rem; flex: 1; min-width: 0;
}
.branch-label-edit:focus { background: rgba(74, 125, 255, 0.1); }

.branch-target {
  color: var(--text-muted); font-size: 0.65rem; font-family: var(--mono);
  margin-left: 0.5rem; flex-shrink: 0; padding: 0.15rem 0.35rem;
  border-radius: 3px; cursor: pointer; opacity: 0.4; transition: opacity 0.1s;
}
.branch-btn:hover .branch-target { opacity: 0.8; }
.branch-target:hover { opacity: 1 !important; background: rgba(74, 125, 255, 0.15); }

.add-branch-btn {
  background: none; border: 1px dashed var(--border); color: var(--text-muted);
  font-size: 0.8rem; padding: 0.6rem; border-radius: 8px; cursor: pointer;
  text-align: center; width: 100%; opacity: 0.5; transition: opacity 0.1s, border-color 0.1s;
}
.add-branch-btn:hover { opacity: 1; border-color: var(--accent); color: var(--accent); }

/* Node footer */
.node-footer {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 1rem; padding-top: 0.75rem; border-top: 1px solid var(--border);
  opacity: 0.4; transition: opacity 0.15s;
}
.node-footer:hover { opacity: 1; }
.node-id-label { font-size: 0.65rem; color: var(--text-muted); font-family: var(--mono); }
.add-node-btn {
  background: none; border: 1px solid var(--border); color: var(--text-muted);
  font-size: 0.7rem; padding: 0.3rem 0.6rem; border-radius: 4px; cursor: pointer;
}
.add-node-btn:hover { border-color: var(--accent); color: var(--accent); }

/* Terminal */
.terminal-msg {
  text-align: center; color: var(--text-muted); font-size: 0.85rem;
  padding: 1.5rem 0; border-top: 1px solid var(--border); margin-top: 1rem;
}
.start-over-btn {
  display: block; width: 100%; max-width: 300px; margin: 1rem auto 0;
  padding: 0.7rem; background: none; border: 1px solid var(--border);
  border-radius: 8px; color: var(--text-muted); font-size: 0.8rem;
  cursor: pointer; text-align: center;
}
.start-over-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ── FLOATING SAVE FAB ── */

.save-fab {
  position: fixed; bottom: 1.5rem; right: 1.5rem;
  background: var(--accent); color: #fff; border: none;
  padding: 0.75rem 1.75rem; border-radius: 50px;
  font-size: 0.95rem; font-weight: 600; cursor: pointer;
  box-shadow: 0 4px 20px rgba(74, 125, 255, 0.35); z-index: 50;
  transition: background 0.15s, transform 0.1s;
}
.save-fab:hover { background: var(--accent-hover); transform: scale(1.03); }
.save-fab:active { transform: scale(0.97); }
.save-fab:disabled { opacity: 0.7; cursor: wait; }
.save-fab.save-fab-ok { background: var(--green); box-shadow: 0 4px 20px rgba(61, 220, 132, 0.3); }
.save-fab.save-fab-error { background: var(--red); box-shadow: 0 4px 20px rgba(255, 82, 82, 0.3); }

/* ── COPY FAB ── */

.copy-fab {
  position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%);
  background: var(--accent); color: #fff; border: none;
  padding: 0.75rem 1.75rem; border-radius: 50px;
  font-size: 0.95rem; font-weight: 600; cursor: pointer;
  box-shadow: 0 4px 20px rgba(74, 125, 255, 0.35); z-index: 50;
  transition: background 0.15s, transform 0.1s;
  white-space: nowrap;
}
.copy-fab:hover { background: var(--accent-hover); transform: translateX(-50%) scale(1.03); }
.copy-fab:active { transform: translateX(-50%) scale(0.97); }
.copy-fab:disabled { opacity: 0.7; cursor: wait; }
.copy-fab.copy-fab-ok { background: var(--green); box-shadow: 0 4px 20px rgba(61, 220, 132, 0.3); }
.copy-fab.copy-fab-error { background: var(--red); box-shadow: 0 4px 20px rgba(255, 82, 82, 0.3); }

/* ── TARGET PICKER ── */

.target-picker {
  position: fixed; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 8px; max-height: 300px; overflow-y: auto;
  z-index: 60; min-width: 200px; box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}
.target-option {
  padding: 0.5rem 0.75rem; font-size: 0.75rem; font-family: var(--mono);
  color: var(--text-muted); cursor: pointer; border-bottom: 1px solid var(--border);
}
.target-option:last-child { border-bottom: none; }
.target-option:hover { background: rgba(74, 125, 255, 0.1); color: var(--text); }
.target-option.selected { color: var(--accent); font-weight: 600; }

/* ── MODAL ── */

.modal-overlay {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 1rem;
}
.modal {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 12px; padding: 1.5rem; max-width: 400px; width: 100%;
}
.modal-title { font-size: 1rem; font-weight: 700; margin-bottom: 0.5rem; }
.modal-desc { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 1rem; line-height: 1.4; }
.modal-input {
  width: 100%; background: var(--bg-input); border: 1px solid var(--border);
  color: var(--text); font-family: var(--mono); font-size: 0.85rem;
  padding: 0.6rem 0.75rem; border-radius: 6px; outline: none; margin-bottom: 1rem;
}
.modal-input:focus { border-color: var(--accent); }
.modal-buttons { display: flex; gap: 0.5rem; justify-content: flex-end; }
.modal-btn { padding: 0.45rem 1rem; border-radius: 6px; font-size: 0.85rem; cursor: pointer; }
.modal-btn-cancel { background: none; border: 1px solid var(--border); color: var(--text-muted); }
.modal-btn-save { background: var(--accent); border: none; color: #fff; font-weight: 600; }
.modal-btn-save:hover { background: var(--accent-hover); }

/* ── UTILITIES ── */

.hidden { display: none !important; }
.loading { text-align: center; color: var(--text-muted); padding: 4rem 0; font-size: 0.9rem; }
.error-msg { text-align: center; color: var(--red); padding: 3rem 1rem; font-size: 0.9rem; }
