/* Support chat widget (includes/support-widget.php + js/support-chat.js).
   Laid out like the tawk.to widget it replaces: round launcher bottom-right,
   panel with a coloured header, message list, input bar. All selectors are
   prefixed jhsc- so page styles cannot collide with it. */

#jhsc-root {
    --jhsc-brand: #3b5cf5;
    --jhsc-brand-dark: #2a45d1;
    --jhsc-bg: #ffffff;
    --jhsc-soft: #f1f3f9;
    --jhsc-text: #1f2937;
    --jhsc-muted: #6b7280;
    --jhsc-border: #e5e7eb;
    --jhsc-ok: #16a34a;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.45;
    color: var(--jhsc-text);
}
#jhsc-root *, #jhsc-root *::before, #jhsc-root *::after { box-sizing: border-box; }

/* ── Launcher ─────────────────────────────────────────── */
.jhsc-launcher {
    position: fixed; right: 20px; bottom: 20px; z-index: 2147483000;
    width: 60px; height: 60px; border-radius: 50%; border: 0; cursor: pointer;
    background: var(--jhsc-brand); color: #fff;
    box-shadow: 0 6px 20px rgba(59, 92, 245, .45);
    display: flex; align-items: center; justify-content: center;
    transition: transform .15s ease, background .15s ease;
}
.jhsc-launcher:hover { transform: scale(1.06); background: var(--jhsc-brand-dark); }
.jhsc-launcher:focus-visible { outline: 3px solid #a5b4fc; outline-offset: 3px; }
.jhsc-launcher svg { width: 28px; height: 28px; }
.jhsc-launcher .jhsc-ico-close { display: none; }
#jhsc-root.jhsc-open .jhsc-launcher .jhsc-ico-chat { display: none; }
#jhsc-root.jhsc-open .jhsc-launcher .jhsc-ico-close { display: block; }

/* ── Panel ────────────────────────────────────────────── */
.jhsc-panel {
    position: fixed; right: 20px; bottom: 92px; z-index: 2147483000;
    width: 370px; height: min(600px, calc(100vh - 120px));
    background: var(--jhsc-bg); border-radius: 16px; overflow: hidden;
    box-shadow: 0 12px 48px rgba(17, 24, 39, .22);
    display: none; flex-direction: column;
    opacity: 0; transform: translateY(12px);
    transition: opacity .18s ease, transform .18s ease;
}
#jhsc-root.jhsc-open .jhsc-panel { display: flex; }
#jhsc-root.jhsc-shown .jhsc-panel { opacity: 1; transform: none; }

.jhsc-header {
    background: linear-gradient(135deg, var(--jhsc-brand), #5b7bff);
    color: #fff; padding: 16px 16px 14px; display: flex; align-items: center; gap: 12px;
    flex-shrink: 0;
}
.jhsc-avatar {
    width: 42px; height: 42px; border-radius: 50%; flex-shrink: 0;
    background: rgba(255, 255, 255, .2); display: flex; align-items: center; justify-content: center;
}
.jhsc-avatar svg { width: 24px; height: 24px; }
.jhsc-title { font-weight: 700; font-size: 16px; margin: 0; }
.jhsc-status { font-size: 12.5px; opacity: .92; display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.jhsc-dot { width: 8px; height: 8px; border-radius: 50%; background: #4ade80; box-shadow: 0 0 0 2px rgba(255,255,255,.35); }
.jhsc-min {
    margin-left: auto; background: transparent; border: 0; color: #fff; cursor: pointer;
    width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center;
}
.jhsc-min:hover { background: rgba(255, 255, 255, .18); }
.jhsc-min svg { width: 20px; height: 20px; }

/* ── Messages ─────────────────────────────────────────── */
.jhsc-body { flex: 1; overflow-y: auto; padding: 16px 14px 8px; background: #fafbfd; overscroll-behavior: contain; }
.jhsc-row { display: flex; flex-direction: column; margin-bottom: 12px; }
.jhsc-row.jhsc-user { align-items: flex-end; }
.jhsc-bubble {
    max-width: 85%; padding: 9px 13px; border-radius: 16px; word-wrap: break-word; overflow-wrap: anywhere;
}
.jhsc-bot .jhsc-bubble { background: var(--jhsc-soft); border-bottom-left-radius: 4px; }
.jhsc-user .jhsc-bubble { background: var(--jhsc-brand); color: #fff; border-bottom-right-radius: 4px; white-space: pre-wrap; }
.jhsc-bubble a { color: var(--jhsc-brand); font-weight: 600; text-decoration: underline; }
.jhsc-user .jhsc-bubble a { color: #fff; }

.jhsc-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.jhsc-chip {
    border: 1px solid var(--jhsc-brand); background: #fff; color: var(--jhsc-brand);
    border-radius: 999px; padding: 6px 12px; font-size: 13px; cursor: pointer; font-family: inherit;
}
.jhsc-chip:hover { background: var(--jhsc-brand); color: #fff; }
.jhsc-chip.jhsc-quiet { border-color: var(--jhsc-border); color: var(--jhsc-muted); }
.jhsc-chip.jhsc-quiet:hover { background: var(--jhsc-soft); color: var(--jhsc-text); }

.jhsc-typing { display: inline-flex; gap: 4px; padding: 12px 14px; }
.jhsc-typing span { width: 7px; height: 7px; border-radius: 50%; background: #9ca3af; animation: jhsc-bounce 1.2s infinite; }
.jhsc-typing span:nth-child(2) { animation-delay: .15s; }
.jhsc-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes jhsc-bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-4px); opacity: 1; } }

/* ── Inline forms (human / feature) ───────────────────── */
.jhsc-form {
    background: #fff; border: 1px solid var(--jhsc-border); border-radius: 12px;
    padding: 14px; margin: 0 0 12px; box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.jhsc-form h4 { margin: 0 0 4px; font-size: 14.5px; }
.jhsc-form p { margin: 0 0 10px; font-size: 12.5px; color: var(--jhsc-muted); }
.jhsc-form label { display: block; font-size: 12px; font-weight: 600; margin: 8px 0 3px; }
.jhsc-form input, .jhsc-form textarea {
    width: 100%; border: 1px solid #d1d5db; border-radius: 8px; padding: 8px 10px;
    font: inherit; color: var(--jhsc-text); background: #fff;
}
.jhsc-form input:focus, .jhsc-form textarea:focus { outline: none; border-color: var(--jhsc-brand); box-shadow: 0 0 0 3px rgba(59,92,245,.15); }
.jhsc-form textarea { resize: vertical; min-height: 76px; }
.jhsc-hp { position: absolute !important; left: -9999px !important; width: 1px; height: 1px; opacity: 0; }
.jhsc-form-btns { display: flex; gap: 8px; margin-top: 12px; }
.jhsc-btn {
    flex: 1; border: 0; border-radius: 8px; padding: 9px 12px; font: inherit; font-weight: 600; cursor: pointer;
    background: var(--jhsc-brand); color: #fff;
}
.jhsc-btn:hover { background: var(--jhsc-brand-dark); }
.jhsc-btn[disabled] { opacity: .6; cursor: default; }
.jhsc-btn.jhsc-sec { background: var(--jhsc-soft); color: var(--jhsc-text); flex: 0 0 auto; }
.jhsc-err { color: #b91c1c; font-size: 12.5px; margin-top: 8px; display: none; }

/* ── Input bar ────────────────────────────────────────── */
.jhsc-input {
    display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px;
    border-top: 1px solid var(--jhsc-border); background: #fff; flex-shrink: 0;
}
.jhsc-input textarea {
    flex: 1; border: 0; resize: none; font: inherit; color: var(--jhsc-text);
    max-height: 110px; min-height: 22px; padding: 6px 2px; outline: none; background: transparent;
}
.jhsc-send {
    width: 38px; height: 38px; border-radius: 50%; border: 0; cursor: pointer; flex-shrink: 0;
    background: var(--jhsc-brand); color: #fff; display: flex; align-items: center; justify-content: center;
}
.jhsc-send[disabled] { background: #c7d2fe; cursor: default; }
.jhsc-send svg { width: 18px; height: 18px; }

.jhsc-foot {
    display: flex; justify-content: center; gap: 14px; padding: 7px 12px 9px;
    font-size: 12px; background: #fff; flex-shrink: 0; border-top: 1px solid #f3f4f6;
}
.jhsc-foot button {
    background: none; border: 0; padding: 0; font: inherit; color: var(--jhsc-muted); cursor: pointer; text-decoration: underline;
}
.jhsc-foot button:hover { color: var(--jhsc-brand); }

/* ── Phone: full screen, like tawk.to on mobile ───────── */
@media (max-width: 480px) {
    .jhsc-panel { right: 0; bottom: 0; width: 100%; height: 100%; border-radius: 0; }
    #jhsc-root.jhsc-open .jhsc-launcher { display: none; }
    .jhsc-launcher { right: 16px; bottom: 16px; width: 56px; height: 56px; }
}

@media print { #jhsc-root { display: none !important; } }
