/* Client live chat widget */
.hp-live-chat {
    position: fixed;
    bottom: 1.25rem;
    right: 1.25rem;
    z-index: 9000;
    font-family: inherit;
}
.hp-live-chat-launcher {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 1rem;
    border: none;
    border-radius: 999px;
    background: var(--color-primary, #2563eb);
    color: #fff;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
    font-size: 0.9rem;
    font-weight: 600;
}
.hp-live-chat-launcher:hover {
    filter: brightness(1.05);
}
.hp-live-chat-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #9ca3af;
    flex-shrink: 0;
}
.hp-live-chat-status-dot.is-online {
    background: #22c55e;
}
.hp-live-chat-status-dot.is-offline {
    background: #9ca3af;
}
.hp-live-chat-panel[hidden],
.hp-admin-live-chat-panel[hidden] {
    display: none !important;
}
.hp-live-chat-panel {
    position: absolute;
    bottom: calc(100% + 0.5rem);
    right: 0;
    width: min(380px, calc(100vw - 2rem));
    height: 460px;
    max-height: calc(100vh - 6rem);
    display: flex;
    flex-direction: column;
    background: var(--color-surface, #fff);
    border: 1px solid var(--color-border, #e5e7eb);
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
    overflow: hidden;
    isolation: isolate;
}
.hp-live-chat-end-modal {
    position: absolute;
    inset: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.hp-live-chat-end-modal[hidden] {
    display: none !important;
}
.hp-live-chat-end-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    cursor: default;
}
.hp-live-chat-end-modal-dialog {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 17rem;
    padding: 1.15rem 1.25rem;
    background: var(--color-surface, #fff);
    border-radius: 10px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
    border: 1px solid var(--color-border, #e5e7eb);
}
.hp-live-chat-end-modal-title {
    margin: 0 0 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    color: inherit;
}
.hp-live-chat-end-modal-text {
    margin: 0 0 1rem;
    font-size: 0.8125rem;
    line-height: 1.45;
    color: var(--color-text-muted, #6b7280);
}
.hp-live-chat-end-modal-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: flex-end;
}
.hp-live-chat-end-modal-confirm {
    background: #dc2626 !important;
    color: #fff !important;
    border: 1px solid #dc2626 !important;
}
.hp-live-chat-end-modal-confirm:hover {
    background: #b91c1c !important;
    border-color: #b91c1c !important;
    color: #fff !important;
}
.hp-live-chat-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--color-border, #e5e7eb);
    background: var(--color-bg-muted, #f9fafb);
}
.hp-live-chat-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    flex: 1;
}
.hp-live-chat-header-status {
    font-size: 0.75rem;
    color: var(--color-text-muted, #6b7280);
}
.hp-live-chat-close {
    border: none;
    background: transparent;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    color: inherit;
    padding: 0 0.25rem;
}
.hp-live-chat-offline {
    padding: 1rem;
    text-align: center;
    font-size: 0.9rem;
}
.hp-live-chat-offline p {
    margin: 0 0 0.75rem;
}
.hp-live-chat-body {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.hp-live-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.hp-live-chat-msg {
    max-width: 88%;
    padding: 0.5rem 0.75rem;
    border-radius: 10px;
    font-size: 0.875rem;
    line-height: 1.4;
    white-space: pre-wrap;
    word-break: break-word;
}
.hp-live-chat-msg--client {
    align-self: flex-end;
    background: var(--color-primary, #2563eb);
    color: #fff;
}
.hp-live-chat-msg--staff {
    align-self: flex-start;
    background: var(--color-bg-muted, #f3f4f6);
    color: inherit;
}
.hp-live-chat-msg--bot {
    align-self: flex-start;
    background: linear-gradient(135deg, #eef2ff 0%, #e0e7ff 100%);
    color: #1e1b4b;
    border: 1px solid #c7d2fe;
}
.hp-live-chat-msg--system {
    align-self: center;
    background: transparent;
    color: var(--color-text-muted, #6b7280);
    font-size: 0.8rem;
    text-align: center;
    max-width: 100%;
}
.hp-live-chat-msg-meta {
    display: block;
    font-size: 0.7rem;
    opacity: 0.75;
    margin-bottom: 0.15rem;
}
.hp-live-chat-typing,
.hp-admin-live-chat-typing {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.75rem;
    margin: 0 1rem 0.25rem;
    font-size: 0.75rem;
    color: var(--color-text-muted, #6b7280);
    flex-shrink: 0;
}
.hp-live-chat-typing[hidden],
.hp-admin-live-chat-typing[hidden] {
    display: none !important;
}
.hp-live-chat-typing-dots {
    display: inline-flex;
    align-items: center;
    gap: 3px;
}
.hp-live-chat-typing-dots span {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.5;
    animation: hp-live-chat-typing-bounce 1.2s ease-in-out infinite;
}
.hp-live-chat-typing-dots span:nth-child(2) {
    animation-delay: 0.15s;
}
.hp-live-chat-typing-dots span:nth-child(3) {
    animation-delay: 0.3s;
}
@keyframes hp-live-chat-typing-bounce {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.45;
    }
    30% {
        transform: translateY(-3px);
        opacity: 1;
    }
}
.hp-admin-live-chat-typing {
    margin: 0 0.5rem 0.25rem;
    flex-shrink: 0;
}
.hp-admin-live-chat-transfer-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
    margin-bottom: 0.35rem;
}
.hp-admin-live-chat-transfer-row .hp-admin-live-chat-dept {
    flex: 1;
    min-width: 120px;
}
.hp-live-chat-start {
    padding: 1.5rem 1rem;
    text-align: center;
    font-size: 0.9rem;
}
.hp-live-chat-issue {
    padding: 0.75rem 1rem 1rem;
}
.hp-live-chat-issue-lead {
    margin: 0 0 0.5rem;
    font-size: 0.875rem;
    color: var(--color-text-muted, #6b7280);
}
.hp-live-chat-issue-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-top: 0.5rem;
}
.hp-live-chat-waiting-note {
    margin: 0;
    padding: 0.35rem 1rem;
    font-size: 0.8rem;
    color: var(--color-text-muted, #6b7280);
    text-align: center;
    background: var(--color-bg-muted, #f9fafb);
    border-top: 1px solid var(--color-border, #e5e7eb);
}
.hp-live-chat-footer {
    padding: 0.5rem 0.75rem 0.75rem;
    border-top: 1px solid var(--color-border, #e5e7eb);
}
.hp-live-chat-input {
    width: 100%;
    resize: none;
    border: 1px solid var(--color-border, #e5e7eb);
    border-radius: 8px;
    padding: 0.5rem;
    font-family: inherit;
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}
.hp-live-chat-footer-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}
.hp-live-chat-closed-bar {
    flex-shrink: 0;
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--color-border, #e5e7eb);
    background: var(--color-bg-muted, #f9fafb);
    text-align: center;
}
.hp-live-chat-closed-title {
    margin: 0 0 0.35rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-text, #111827);
}
.hp-live-chat-closed-ticket {
    margin: 0 0 0.65rem;
    font-size: 0.8rem;
}
.hp-live-chat-closed-ticket a {
    color: var(--color-primary, #2563eb);
}
.hp-live-chat-closed-bar .btn {
    width: 100%;
    margin-top: 0.35rem;
}
.hp-live-chat-closed-bar .btn:first-of-type {
    margin-top: 0;
}
.hp-live-chat-email-sent {
    margin: 0 0 0.5rem;
    font-size: 0.75rem;
    color: var(--color-text-muted, #6b7280);
}
html[data-theme="dark"] .hp-live-chat-panel,
.theme-dark .hp-live-chat-panel {
    background: #1f2937;
    border-color: #374151;
}
html[data-theme="dark"] .hp-live-chat-msg--staff,
.theme-dark .hp-live-chat-msg--staff {
    background: #374151;
}

/* Admin pop-out */
.hp-admin-live-chat {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    z-index: 10050;
    font-family: inherit;
}
.hp-admin-live-chat-launcher {
    position: relative;
    width: 52px;
    height: 52px;
    border: none;
    border-radius: 50%;
    background: #465fff;
    color: #fff;
    font-size: 1.35rem;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}
.hp-admin-live-chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: #ef4444;
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
}
.hp-admin-live-chat-panel {
    position: absolute;
    bottom: calc(100% + 0.5rem);
    right: 0;
    width: 380px;
    height: 480px;
    max-height: calc(100vh - 5rem);
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    overflow: hidden;
}
.hp-admin-live-chat-header {
    display: flex;
    align-items: center;
    padding: 0.6rem 0.75rem;
    background: #f8fafc;
    border-bottom: 1px solid #e5e7eb;
    gap: 0.5rem;
}
.hp-admin-live-chat-header h2 {
    margin: 0;
    font-size: 0.95rem;
    flex: 1;
}
.hp-admin-live-chat-layout {
    display: flex;
    flex: 1;
    min-height: 0;
}
.hp-admin-live-chat-list {
    width: 38%;
    border-right: 1px solid #e5e7eb;
    overflow-y: auto;
    font-size: 0.8rem;
}
.hp-admin-live-chat-list-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 0.55rem 0.6rem;
    border: none;
    border-bottom: 1px solid #f3f4f6;
    background: #fff;
    cursor: pointer;
}
.hp-admin-live-chat-list-item:hover,
.hp-admin-live-chat-list-item.is-active {
    background: #eff6ff;
}
.hp-admin-live-chat-list-item strong {
    display: block;
    font-size: 0.8rem;
}
.hp-admin-live-chat-list-item span {
    color: #6b7280;
    font-size: 0.72rem;
}
.hp-admin-live-chat-thread {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
}
.hp-admin-live-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
    font-size: 0.8rem;
}
.hp-admin-live-chat-msg {
    margin-bottom: 0.4rem;
    padding: 0.35rem 0.5rem;
    border-radius: 6px;
    white-space: pre-wrap;
    word-break: break-word;
}
.hp-admin-live-chat-msg--staff {
    background: #dbeafe;
    margin-left: 1rem;
}
.hp-admin-live-chat-msg--client {
    background: #f3f4f6;
    margin-right: 1rem;
}
.hp-admin-live-chat-msg--system {
    color: #6b7280;
    font-size: 0.72rem;
    text-align: center;
}
.hp-admin-live-chat-compose {
    padding: 0.5rem;
    border-top: 1px solid #e5e7eb;
}
.hp-admin-live-chat-compose textarea {
    width: 100%;
    resize: none;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 0.4rem;
    font-size: 0.8rem;
    margin-bottom: 0.35rem;
}
.hp-admin-live-chat-convert-row {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    margin-bottom: 0.35rem;
}
.hp-admin-live-chat-dept-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: #6b7280;
}
.hp-admin-live-chat-dept {
    width: 100%;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 0.35rem 0.4rem;
    font-size: 0.8rem;
    background: #fff;
}
.hp-admin-live-chat-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}
.hp-admin-live-chat-actions button {
    font-size: 0.72rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    border: 1px solid #d1d5db;
    background: #fff;
    cursor: pointer;
}
.hp-admin-live-chat-actions button.btn-primary {
    background: #465fff;
    color: #fff;
    border-color: #465fff;
}
.hp-admin-live-chat-empty {
    padding: 1rem;
    color: #6b7280;
    font-size: 0.85rem;
    text-align: center;
}
.hp-admin-live-chat-accept {
    padding: 0.5rem;
    margin: 0 0.35rem 0.35rem;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    flex-shrink: 0;
}
.hp-admin-live-chat-accept-text {
    margin: 0 0 0.5rem;
    font-size: 0.78rem;
    line-height: 1.35;
    color: #1e40af;
}
.hp-admin-live-chat-accept-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}
.hp-admin-live-chat-accept-actions .btn-primary,
.hp-admin-live-chat-accept-actions button.btn-primary {
    font-size: 0.75rem;
    padding: 0.35rem 0.65rem;
}
.hp-admin-live-chat-accept-actions button {
    font-size: 0.72rem;
    padding: 0.3rem 0.55rem;
}

/* Guest captcha step (inside chat panel) */
.hp-live-chat-captcha {
    padding: 0.75rem 1rem 1rem;
    border-top: 1px solid var(--color-border, #e5e7eb);
    flex-shrink: 0;
}
.hp-live-chat-captcha-lead {
    margin: 0 0 0.65rem;
    font-size: 0.8rem;
    line-height: 1.4;
    color: var(--color-text-muted, #6b7280);
}
.hp-live-chat-captcha-default {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.65rem;
}
.hp-live-chat-captcha-img {
    display: block;
    border-radius: 6px;
    border: 1px solid var(--color-border, #e5e7eb);
}
.hp-live-chat-captcha-puzzle {
    margin-bottom: 0.65rem;
}
.hp-live-chat-captcha-puzzle .captcha-puzzle-widget {
    max-width: 100%;
}
