@import url('https://fonts.googleapis.com/css2?family=Syne:wght@600;700;800&family=DM+Sans:wght@400;500;600&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg: #0a0d0f; --bg2: #111518; --panel: #161b1e; --panel2: #1c2226;
  --border: #252d32; --txt: #e8edef; --txt2: #8a9499; --txt3: #4f5c62;
  --lime: #b8f542; --lime2: #7aa32b; --amber: #f5b342; --red: #f55b5b; --blue: #5bc4f5;
  --r: 12px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'DM Sans', sans-serif; background: var(--bg); color: var(--txt); height: 100vh; overflow: hidden; display: flex; flex-direction: column; -webkit-font-smoothing: antialiased; }
.accent { color: var(--lime); }
.hidden { display: none !important; }
.mono { font-family: 'JetBrains Mono', monospace; }

/* ---- NAV ---- */
.crm-nav { height: 54px; display: flex; align-items: center; padding: 0 20px; border-bottom: 1px solid var(--border); background: var(--bg); flex-shrink: 0; gap: 16px; z-index: 10; }
.nav-logo { font-family: 'Syne', sans-serif; font-size: 22px; font-weight: 800; }
.nav-center { flex: 1; font-size: 14px; color: var(--txt2); text-align: center; }
.nav-right { display: flex; align-items: center; gap: 12px; }
.nav-user { font-size: 13px; color: var(--txt2); }
.nav-link { font-size: 13px; color: var(--txt2); text-decoration: none; padding: 6px 12px; border: 1px solid var(--border); border-radius: 8px; transition: all .15s; }
.nav-link:hover { border-color: var(--lime2); color: var(--txt); }
.nav-btn { background: none; border: 1px solid var(--border); color: var(--txt2); padding: 6px 12px; border-radius: 8px; cursor: pointer; font-family: 'DM Sans', sans-serif; font-size: 13px; }
.nav-btn:hover { border-color: var(--txt2); color: var(--txt); }

/* ---- BODY LAYOUT ---- */
.crm-body { flex: 1; display: flex; overflow: hidden; }

/* ---- SIDEBAR ---- */
.crm-sidebar { width: 280px; border-right: 1px solid var(--border); display: flex; flex-direction: column; background: var(--panel); flex-shrink: 0; }
.sidebar-header { padding: 12px; border-bottom: 1px solid var(--border); }
.busca-input { width: 100%; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; color: var(--txt); font-size: 14px; outline: none; font-family: 'DM Sans', sans-serif; }
.busca-input:focus { border-color: var(--lime2); }
.busca-input::placeholder { color: var(--txt3); }
.leads-list { flex: 1; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
.leads-list::-webkit-scrollbar { width: 5px; }
.leads-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.lead-item { padding: 14px 16px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background .1s; display: flex; gap: 12px; align-items: center; }
.lead-item:hover { background: var(--panel2); }
.lead-item.active { background: var(--panel2); border-left: 3px solid var(--lime); }
.lead-avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--bg2); display: flex; align-items: center; justify-content: center; font-size: 16px; font-weight: 700; color: var(--lime); flex-shrink: 0; }
.lead-item-info { flex: 1; min-width: 0; }
.lead-item-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lead-item-preview { font-size: 12px; color: var(--txt3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 3px; }
.lead-item-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }
.lead-item-time { font-size: 10px; color: var(--txt3); }
.lead-item-tag { font-size: 9px; padding: 2px 6px; border-radius: 99px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.tag-Lead { background: rgba(184,245,66,.15); color: var(--lime); }
.tag-novo { background: rgba(255,255,255,.06); color: var(--txt3); }
.tag-qualificado { background: rgba(91,196,245,.15); color: var(--blue); }
.tag-agendou { background: rgba(245,179,66,.15); color: var(--amber); }
.tag-comprou { background: rgba(184,245,66,.25); color: var(--lime); }
.tag-perdido { background: rgba(245,91,91,.12); color: var(--red); }

/* ---- CHAT ---- */
.crm-chat { flex: 1; display: flex; flex-direction: column; background: var(--bg2); min-width: 0; }
.chat-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; }
.chat-empty-icon { font-size: 48px; opacity: .3; }
.chat-empty-txt { color: var(--txt3); font-size: 15px; }

.chat-header { padding: 14px 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; background: var(--panel); }
.chat-header-name { font-weight: 700; font-size: 16px; }
.chat-header-phone { font-size: 12px; color: var(--txt2); font-family: 'JetBrains Mono', monospace; }
.chat-header-tag { font-size: 11px; padding: 4px 10px; border-radius: 99px; font-weight: 600; }

.chat-messages { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 6px; scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
.chat-messages::-webkit-scrollbar { width: 5px; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.msg-bubble { max-width: 65%; padding: 10px 14px; border-radius: 14px; font-size: 14px; line-height: 1.5; position: relative; word-wrap: break-word; }
.msg-bubble.recebida { background: var(--panel); align-self: flex-start; border-bottom-left-radius: 4px; }
.msg-bubble.enviada { background: rgba(184,245,66,.12); align-self: flex-end; border-bottom-right-radius: 4px; }
.msg-time { font-size: 10px; color: var(--txt3); margin-top: 4px; text-align: right; }
.msg-media img { max-width: 100%; border-radius: 8px; cursor: pointer; }
.msg-media video { max-width: 100%; border-radius: 8px; }
.msg-media audio { width: 100%; margin-top: 6px; }
.msg-media .doc-link { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; color: var(--blue); text-decoration: none; font-size: 13px; margin-top: 4px; }
.msg-media .doc-link:hover { border-color: var(--blue); }

.chat-input-bar { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; gap: 10px; align-items: flex-end; background: var(--panel); }
.chat-input-bar textarea { flex: 1; background: var(--bg); border: 1px solid var(--border); border-radius: 12px; padding: 12px 16px; color: var(--txt); font-family: 'DM Sans', sans-serif; font-size: 14px; outline: none; resize: none; max-height: 120px; line-height: 1.4; }
.chat-input-bar textarea:focus { border-color: var(--lime2); }
.chat-input-bar textarea::placeholder { color: var(--txt3); }
.send-btn { width: 44px; height: 44px; border-radius: 50%; background: var(--lime); border: none; color: #0a0d0f; font-size: 18px; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: opacity .15s; }
.send-btn:hover { opacity: .85; }

/* ---- DETAILS PANEL ---- */
.crm-details { width: 300px; border-left: 1px solid var(--border); background: var(--panel); overflow-y: auto; flex-shrink: 0; scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
.crm-details::-webkit-scrollbar { width: 5px; }
.crm-details::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.details-section { padding: 16px 18px; border-bottom: 1px solid var(--border); }
.details-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--lime); margin-bottom: 10px; }
.detail-row { display: flex; justify-content: space-between; align-items: center; padding: 5px 0; font-size: 13px; }
.detail-label { color: var(--txt2); }
.detail-value { font-family: 'JetBrains Mono', monospace; font-size: 12px; color: var(--txt); max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: right; }

.evt-row { display: flex; align-items: center; gap: 6px; padding: 4px 0; font-size: 12px; }
.evt-st { font-family: 'JetBrains Mono', monospace; font-size: 10px; font-weight: 600; padding: 2px 6px; border-radius: 4px; }
.evt-st.sent { color: var(--lime); background: rgba(184,245,66,.1); }
.evt-st.error { color: var(--red); background: rgba(245,91,91,.1); }
.evt-st.dry_run { color: var(--amber); background: rgba(245,179,66,.1); }

.tags-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-action-btn { padding: 8px 14px; border-radius: 99px; border: 1px solid var(--border); background: transparent; color: var(--txt2); cursor: pointer; font-family: 'DM Sans', sans-serif; font-size: 12px; font-weight: 600; transition: all .15s; }
.tag-action-btn:hover { border-color: var(--lime); color: var(--lime); }
.tag-action-btn.active { background: var(--lime); color: #0a0d0f; border-color: var(--lime); }
.tag-action-btn.has-event::after { content: ' ⚡'; opacity: .6; }
.valor-input { width: 100%; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; color: var(--txt); font-size: 14px; outline: none; }

/* ---- TOAST ---- */
.crm-toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(16px); background: var(--panel2); border: 1px solid var(--border); padding: 10px 18px; border-radius: 10px; font-size: 13px; opacity: 0; transition: all .2s; pointer-events: none; z-index: 200; box-shadow: 0 8px 24px rgba(0,0,0,.5); }
.crm-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---- RESPONSIVE ---- */
@media (max-width: 900px) {
  .crm-sidebar { width: 220px; }
  .crm-details { width: 240px; }
}
@media (max-width: 700px) {
  .crm-details { display: none; }
  .crm-sidebar { width: 200px; }
}

/* Separador de data */
.msg-date-separator { display: flex; align-items: center; justify-content: center; padding: 12px 0 6px; }
.msg-date-separator span { font-size: 11px; color: var(--txt3); background: var(--panel); padding: 4px 14px; border-radius: 8px; font-weight: 500; }

.tag-input { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; color: var(--txt); font-family: 'DM Sans', sans-serif; font-size: 13px; outline: none; }
.tag-input:focus { border-color: var(--lime2); }
.modal-textarea { background: var(--bg) !important; border: 1px solid var(--border) !important; border-radius: 10px !important; padding: 12px 16px !important; color: var(--txt) !important; font-family: 'DM Sans', sans-serif !important; font-size: 14px !important; outline: none !important; resize: vertical !important; width: 100% !important; }



/* Landing Page Editor - Full Page */
.lp-editor-panel {
  flex: 1; padding: 20px 24px; overflow-y: auto; max-height: 100%;
  scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}
.lp-editor-panel::-webkit-scrollbar { width: 5px; }
.lp-editor-panel::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.lp-editor-panel label { font-size: 13px; font-weight: 600; color: var(--txt); display: block; margin: 8px 0 4px; }
.lp-editor-panel input[type=text], .lp-editor-panel input[type=email], .lp-editor-panel input[type=tel], .lp-editor-panel input { width: 100%; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; color: var(--txt); font-size: 14px; font-family: 'DM Sans', sans-serif; outline: none; }
.lp-editor-panel input:focus, .lp-editor-panel textarea:focus { border-color: var(--lime2); }
.lp-section-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--lime); padding: 10px 0 4px; border-top: 1px solid var(--border); margin-top: 4px; }

.lp-preview-panel {
  width: 340px; background: #1a1f22; border-left: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: center; padding: 20px 16px;
  overflow-y: auto; flex-shrink: 0;
}
.lp-preview-label { font-size: 11px; font-weight: 700; color: var(--txt3); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 14px; }
.lp-phone-frame { width: 290px; min-height: 520px; background: #0a0d0f; border-radius: 28px; border: 2px solid #333; overflow: hidden; }
.lp-phone-notch { width: 80px; height: 6px; background: #333; border-radius: 3px; margin: 10px auto; }
.lp-phone-content { padding: 14px; display: flex; flex-direction: column; align-items: center; text-align: center; }
.lp-phone-content .pv-img { max-width: 64px; max-height: 64px; border-radius: 12px; margin-bottom: 12px; }
.lp-phone-content .pv-titulo { font-size: 17px; font-weight: 700; margin-bottom: 4px; color: #e8edef; line-height: 1.2; }
.lp-phone-content .pv-subtitulo { font-size: 12px; color: #8a9499; margin-bottom: 4px; }
.lp-phone-content .pv-descricao { font-size: 10px; color: #6b7680; margin-bottom: 16px; line-height: 1.4; }
.lp-phone-content .pv-form-titulo { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 10px; text-align: left; width: 100%; }
.lp-phone-content .pv-field { width: 100%; margin-bottom: 10px; text-align: left; }
.lp-phone-content .pv-field-label { font-size: 10px; font-weight: 600; color: #8a9499; margin-bottom: 4px; }
.lp-phone-content .pv-field-input { width: 100%; background: #161b1e; border: 1px solid #252d32; border-radius: 8px; padding: 9px 12px; color: #4f5c62; font-size: 11px; }
.lp-phone-content .pv-options { display: flex; flex-wrap: wrap; gap: 5px; }
.lp-phone-content .pv-opt { padding: 6px 12px; border-radius: 99px; border: 1px solid #252d32; font-size: 10px; color: #8a9499; }
.lp-phone-content .pv-btn { width: 100%; padding: 11px; border: none; border-radius: 12px; font-size: 13px; font-weight: 700; margin-top: 10px; color: #0a0d0f; display: flex; align-items: center; justify-content: center; gap: 5px; }
.lp-phone-content .pv-footer { font-size: 8px; color: #444; margin-top: 12px; }

@media (max-width: 700px) { .lp-preview-panel { display: none; } }
