
.eg-chat { position: fixed; right: 18px; bottom: 18px; z-index: 900; font-family: Inter, system-ui, sans-serif; }
.eg-chat-fab {
  width: 58px; height: 58px; border-radius: 50%; border: 0; cursor: pointer;
  background: linear-gradient(135deg, #00A86B 0%, #059669 100%);
  box-shadow: 0 10px 28px rgba(0,168,107,.4); display: flex; align-items: center; justify-content: center;
  transition: transform .15s;
}
.eg-chat-fab:hover { transform: scale(1.05); }
.eg-chat-panel {
  position: absolute; right: 0; bottom: 0; width: 360px; max-width: calc(100vw - 24px);
  height: 520px; max-height: calc(100vh - 40px); background: #0f1419; border-radius: 20px;
  overflow: hidden; display: flex; flex-direction: column;
  box-shadow: 0 20px 50px rgba(0,0,0,.35); border: 1px solid rgba(255,255,255,.06);
}
.eg-chat-panel[hidden], .eg-chat-panel[style*="display: none"] { /* handled inline */ }
.eg-chat-head {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px;
  background: linear-gradient(180deg, #1a2332 0%, #121820 100%); border-bottom: 1px solid rgba(255,255,255,.06);
}
.eg-chat-avatar {
  width: 42px; height: 42px; border-radius: 14px; background: linear-gradient(135deg,#00A86B,#34d399);
  color: #fff; font-weight: 800; display: flex; align-items: center; justify-content: center;
}
.eg-chat-title { color: #f8fafc; font-weight: 700; font-size: 0.95rem; }
.eg-chat-status { font-size: 0.75rem; color: #94a3b8; }
.eg-chat-status.on { color: #34d399; }
.eg-chat-status.on::before { content: ''; display: inline-block; width: 7px; height: 7px; background: #34d399; border-radius: 50%; margin-right: 6px; }
.eg-chat-x {
  margin-left: auto; background: transparent; border: 0; color: #94a3b8; font-size: 1.4rem; cursor: pointer; line-height: 1;
}
.eg-chat-body {
  flex: 1; overflow-y: auto; padding: 16px 14px; background:
    radial-gradient(ellipse at top, #15202b 0%, #0f1419 55%);
  display: flex; flex-direction: column; gap: 8px;
}
.eg-msg { display: flex; max-width: 85%; }
.eg-msg-in { align-self: flex-start; }
.eg-msg-out { align-self: flex-end; }
.eg-bubble {
  padding: 10px 14px; border-radius: 16px; font-size: 0.9rem; line-height: 1.45; word-break: break-word;
}
.eg-msg-in .eg-bubble {
  background: #1e293b; color: #e2e8f0; border-bottom-left-radius: 4px;
}
.eg-msg-out .eg-bubble {
  background: linear-gradient(135deg, #00A86B, #059669); color: #fff; border-bottom-right-radius: 4px;
}
.eg-chat-foot {
  display: flex; gap: 8px; padding: 12px; background: #121820; border-top: 1px solid rgba(255,255,255,.06);
}
.eg-chat-foot input {
  flex: 1; border: 0; border-radius: 22px; padding: 12px 16px; background: #1e293b; color: #f1f5f9; font-size: 0.9rem; outline: none;
}
.eg-chat-send {
  width: 44px; height: 44px; border-radius: 50%; border: 0; cursor: pointer;
  background: linear-gradient(135deg, #00A86B, #059669); display: flex; align-items: center; justify-content: center;
}
@media (max-width: 480px) {
  .eg-chat-panel { width: calc(100vw - 16px); height: calc(100vh - 24px); border-radius: 16px; }
}

.eg-msg-name { font-size: 0.7rem; color: #94a3b8; margin-bottom: 2px; padding-left: 4px; }
.eg-sys { text-align: center; font-size: 0.75rem; color: #64748b; margin: 8px 0; }
.eg-attach { max-width: 200px; border-radius: 10px; display: block; margin-bottom: 6px; }
.role-admin { color: #f59e0b; }
.role-support { color: #38bdf8; }
.role-super { color: #a78bfa; }

.eg-chat-panel.is-open { display: flex !important; flex-direction: column; }

/* Energisyfy v20 chat polish */
.eg-chat-root{position:fixed;right:20px;bottom:20px;z-index:2147483000;font-family:inherit}
.eg-chat-fab{width:58px;height:58px;border:0;border-radius:50%;background:#00a86b;color:#fff;font-size:24px;cursor:pointer;box-shadow:0 12px 30px rgba(0,168,107,.28);transition:transform .18s ease,box-shadow .18s ease}
.eg-chat-fab:hover{transform:translateY(-2px);box-shadow:0 16px 36px rgba(0,168,107,.34)}
.eg-chat-panel{position:fixed;right:20px;bottom:92px;width:380px;max-width:calc(100vw - 24px);height:540px;max-height:calc(100vh - 120px);display:flex;flex-direction:column;background:#fff;border:1px solid #e2e8f0;border-radius:20px;overflow:hidden;box-shadow:0 24px 70px rgba(15,23,42,.22);opacity:0;transform:translateY(12px) scale(.98);pointer-events:none;transition:opacity .18s ease,transform .18s ease}
.eg-chat-panel.is-open{opacity:1;transform:none;pointer-events:auto}
.eg-chat-head{display:flex;align-items:center;gap:11px;padding:15px 16px;background:linear-gradient(135deg,#062d23,#00a86b);color:#fff}
.eg-chat-avatar{width:40px;height:40px;border-radius:13px;display:grid;place-items:center;background:rgba(255,255,255,.16);font-weight:800}
.eg-chat-head-copy{min-width:0;flex:1}.eg-chat-title{font-weight:800}.eg-chat-status{font-size:.78rem;opacity:.82;margin-top:2px}.eg-chat-status.on{opacity:1}.eg-chat-x{width:36px;height:36px;border:0;background:rgba(255,255,255,.1);color:#fff;border-radius:10px;font-size:22px;cursor:pointer}.eg-chat-body{flex:1;overflow:auto;padding:16px;background:#f8fafc}.eg-chat-foot{display:flex;gap:8px;padding:12px;border-top:1px solid #e2e8f0;background:#fff}.eg-chat-foot input{min-width:0;flex:1;border:1px solid #dbe4ec;border-radius:13px;padding:11px 13px;outline:none;background:#fff;color:#0f172a}.eg-chat-foot input:focus{border-color:#00a86b;box-shadow:0 0 0 3px rgba(0,168,107,.1)}.eg-chat-send{width:44px;height:44px;border:0;border-radius:13px;background:#00a86b;color:#fff;font-size:20px;cursor:pointer}.eg-msg{display:flex;margin:0 0 10px}.eg-msg-in{justify-content:flex-start}.eg-msg-out{justify-content:flex-end}.eg-bubble{max-width:78%;padding:10px 12px;border-radius:15px;background:#fff;border:1px solid #e2e8f0;box-shadow:0 2px 8px rgba(15,23,42,.04);white-space:pre-wrap;word-break:break-word}.eg-msg-out .eg-bubble{background:#e9f9f2;border-color:#c8efde}.eg-msg-agent{font-size:.72rem;font-weight:700;color:#00885a;margin-bottom:4px}.eg-sys{margin:12px auto;text-align:center;max-width:90%;font-size:.78rem;color:#64748b;background:#eef2f7;border-radius:999px;padding:7px 11px}.eg-chat-closed{padding:18px;background:#fff;border-top:1px solid #e2e8f0}.eg-chat-closed-title{font-weight:800;color:#0f172a;font-size:1rem}.eg-chat-closed-text{margin-top:6px;color:#64748b;line-height:1.45;font-size:.88rem}.eg-chat-closed-actions{display:flex;gap:8px;flex-wrap:wrap;margin-top:14px}.eg-chat-new,.eg-chat-ticket{display:inline-flex;align-items:center;justify-content:center;min-height:40px;padding:0 14px;border-radius:11px;font-weight:700;text-decoration:none}.eg-chat-new{border:0;background:#00a86b;color:#fff;cursor:pointer}.eg-chat-ticket{border:1px solid #dbe4ec;color:#0f172a;background:#fff}
@media(max-width:560px){.eg-chat-root{right:12px;bottom:12px}.eg-chat-panel{right:12px;bottom:82px;width:calc(100vw - 24px);height:min(600px,calc(100vh - 100px));max-height:none}.eg-chat-fab{width:54px;height:54px}}

/* Admin chat surface */
.lc-main .eg-msg{display:flex;margin-bottom:12px}.lc-main .eg-msg-in{justify-content:flex-start}.lc-main .eg-msg-out{justify-content:flex-end}.lc-main .eg-bubble{max-width:min(72%,620px);padding:11px 13px;border-radius:15px;background:#fff;border:1px solid #e2e8f0;color:#0f172a;box-shadow:0 2px 8px rgba(15,23,42,.04)}.lc-main .eg-msg-out .eg-bubble{background:#e9f9f2;border-color:#c8efde}.lc-main .eg-msg-name{font-size:.72rem;color:#64748b;margin-bottom:4px;font-weight:700}.lc-main .eg-sys{margin:12px auto}

/* v23 state hardening */
#eg-chat-root [hidden]{display:none !important}
.eg-chat-welcome{margin:auto;max-width:290px;padding:24px 20px;text-align:center;color:#64748b;background:#fff;border:1px solid #e7edf2;border-radius:18px;box-shadow:0 8px 24px rgba(15,23,42,.05)}
.eg-chat-welcome-icon{width:44px;height:44px;margin:0 auto 12px;border-radius:14px;display:grid;place-items:center;background:#e9f9f2;color:#00885a;font-weight:800;font-size:18px}
.eg-chat-welcome strong{display:block;color:#0f172a;font-size:.9rem;line-height:1.45}
.eg-chat-closed{flex:none}
.eg-chat-panel .eg-chat-foot[hidden],.eg-chat-panel .eg-chat-closed[hidden]{display:none !important}

/* v25 visual/state hardening */
.eg-chat-panel{width:420px;height:620px;max-height:calc(100vh - 56px);background:#f8fafc}
.eg-chat-body{min-height:0;gap:10px;padding:18px 16px;background:#f8fafc}
.eg-chat-panel.is-closed .eg-chat-foot{display:none !important}
.eg-chat-panel.is-closed .eg-chat-closed{display:flex !important;flex-direction:column;gap:0;padding:18px 18px 20px;background:#fff;border-top:1px solid #e2e8f0;flex:none}
.eg-chat-closed-title{font-size:1rem;line-height:1.35;color:#0f172a}
.eg-chat-closed-text{margin-top:7px;font-size:.9rem;color:#64748b;line-height:1.5}
.eg-chat-closed-actions{margin-top:14px;display:flex;flex-wrap:wrap;gap:8px}
.eg-msg{width:100%;margin:0 0 2px}
.eg-bubble{width:fit-content;max-width:min(82%,330px);font-size:.9rem;line-height:1.45}
.eg-msg-agent,.eg-msg-name{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.eg-sys{max-width:92%;line-height:1.35}
.eg-chat-welcome{margin:auto}
@media(max-width:560px){.eg-chat-panel{right:8px;bottom:74px;width:calc(100vw - 16px);height:min(650px,calc(100vh - 92px));max-height:none}.eg-chat-body{padding:14px 12px}.eg-bubble{max-width:84%}}

/* Admin chat: compact, stable message rhythm and clear states */
.lc-main{min-height:640px}
.lc-body{display:flex;flex-direction:column;align-items:stretch;gap:4px;min-height:0}
.lc-body .eg-msg{width:100%;margin:0 0 8px;flex:0 0 auto}
.lc-body .eg-msg-in{justify-content:flex-start}
.lc-body .eg-msg-out{justify-content:flex-end}
.lc-body .eg-bubble{width:fit-content;max-width:min(72%,620px);white-space:pre-wrap;overflow-wrap:anywhere}
.lc-body .eg-msg-name{white-space:nowrap}
.lc-body .eg-sys{flex:0 0 auto}
.lc-foot[hidden],.lc-closed[hidden]{display:none !important}
.lc-closed{flex:none}

/* v25.1: never distribute messages across the full chat height */
.lc-body{justify-content:flex-start !important;align-content:flex-start !important;}
.lc-body .eg-msg{align-self:stretch !important;}
.lc-body .eg-msg-in .eg-bubble{align-self:flex-start}
.lc-body .eg-msg-out .eg-bubble{align-self:flex-end}

/* v27 final readability/state polish */
.eg-chat-panel .eg-msg-in .eg-bubble{background:#ffffff !important;color:#172033 !important;border:1px solid #dfe7ef !important;}
.eg-chat-panel .eg-msg-out .eg-bubble{background:#e8f8f1 !important;color:#172033 !important;border:1px solid #bfe8d5 !important;}
.eg-chat-panel .eg-msg-agent{color:#00885a !important;}
.eg-chat-panel .eg-sys{color:#53657b !important;background:#eef3f7 !important;border:1px solid #e3eaf0;}
.eg-chat-panel .eg-chat-status{color:#dbe7e2;line-height:1.35;}
.eg-chat-panel .eg-chat-status.on{color:#b8f1d6;}
.eg-chat-panel .eg-chat-body{padding:20px 18px;}
.eg-chat-panel .eg-bubble{max-width:min(84%,340px);}
.eg-chat-panel .eg-chat-closed{padding:20px 18px 22px;}
.eg-chat-panel .eg-chat-closed-actions{gap:9px;}
.eg-chat-panel .eg-chat-new,.eg-chat-panel .eg-chat-ticket{min-height:42px;padding:0 15px;}
@media(max-width:560px){.eg-chat-panel{width:calc(100vw - 12px);right:6px;height:min(680px,calc(100vh - 76px));bottom:70px}.eg-chat-body{padding:16px 12px}.eg-bubble{max-width:88%}}

/* v27 admin chat polish */
.lc-main .lc-body{background:#f8fafc;padding:22px;}
.lc-main .eg-msg-in .eg-bubble{background:#fff !important;color:#172033 !important;border:1px solid #dfe7ef !important;}
.lc-main .eg-msg-out .eg-bubble{background:#e8f8f1 !important;color:#172033 !important;border:1px solid #bfe8d5 !important;}
.lc-main .eg-msg-name{color:#00885a !important;}
.lc-main .eg-sys{color:#53657b !important;background:#eef3f7 !important;border:1px solid #e3eaf0;}
.lc-main .lc-foot[hidden],.lc-main .lc-foot.is-hidden{display:none !important;}
