/* ===============================
   ROOT / BASE
================================ */
:root {
    --hc-primary-1: #5b6df8;
    --hc-primary-2: #7c3aed;
    --hc-accent: #14b8a6;
    --hc-success: #22c55e;
    --hc-warning: #f59e0b;
    --hc-danger-1: #ef4444;
    --hc-danger-2: #dc2626;

    --hc-bg-soft: #f8fafc;
    --hc-bg-panel: rgba(255, 255, 255, 0.96);
    --hc-bg-panel-strong: #ffffff;
    --hc-text-1: #111827;
    --hc-text-2: #4b5563;
    --hc-text-3: #6b7280;
    --hc-border: rgba(148, 163, 184, 0.18);

    --hc-shadow-soft: 0 10px 30px rgba(15, 23, 42, 0.10);
    --hc-shadow-medium: 0 18px 45px rgba(15, 23, 42, 0.16);
    --hc-shadow-strong: 0 25px 60px rgba(15, 23, 42, 0.22);

    --hc-radius-xl: 24px;
    --hc-radius-lg: 18px;
    --hc-radius-md: 14px;

    --hc-font: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

/* ===============================
   CHAT FLOATING BUBBLE
================================ */
#hc-chat-bubble {
    position: fixed;
    right: 28px;
    bottom: 28px;
    width: 70px;
    height: 70px;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--hc-primary-1) 0%, var(--hc-primary-2) 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10000;
    box-shadow:
        0 14px 38px rgba(91, 109, 248, 0.40),
        0 6px 18px rgba(0, 0, 0, 0.12),
        inset 0 1px 0 rgba(255, 255, 255, 0.25);
    border: 2px solid rgba(255, 255, 255, 0.18);
    transition: transform 0.25s ease, box-shadow 0.25s ease, opacity 0.25s ease;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    font-family: var(--hc-font);
    user-select: none;
}

#hc-chat-bubble:hover {
    transform: translateY(-2px) scale(1.06);
    box-shadow:
        0 18px 46px rgba(91, 109, 248, 0.48),
        0 10px 22px rgba(0, 0, 0, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

#hc-chat-bubble:active {
    transform: scale(0.96);
}

.hc-chat-bubble-icon {
    font-size: 1.8rem;
    line-height: 1;
}

/* ===============================
   UNREAD BADGE
================================ */
.hc-chat-notify {
    position: absolute;
    top: -4px;
    right: -2px;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--hc-danger-1), var(--hc-danger-2));
    color: #fff;
    font-size: 12px;
    font-weight: 800;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 16px rgba(239, 68, 68, 0.35);
    border: 2px solid #fff;
}

/* ===============================
   CHAT BOX
================================ */
#hc-chat-box {
    position: fixed;
    right: 28px;
    bottom: 112px;
    width: 430px;
    height: 600px;
    max-height: calc(100vh - 140px);
    background: var(--hc-bg-panel);
    border-radius: 26px;
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 10000;
    box-shadow: var(--hc-shadow-strong);
    border: 1px solid rgba(255, 255, 255, 0.22);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    font-family: var(--hc-font);
    transform-origin: bottom right;
    animation: hcChatSlideIn 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes hcChatSlideIn {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ===============================
   HEADER
================================ */
.hc-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 18px 18px 16px;
    background: linear-gradient(135deg, var(--hc-primary-1) 0%, var(--hc-primary-2) 100%);
    color: #fff;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.hc-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    flex: 1;
}

.hc-header-avatar {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.14);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16);
    flex-shrink: 0;
}

.hc-header-main {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.hc-header-topline {
    display: flex;
    align-items: center;
    gap: 8px;
}

.hc-header-title {
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: -0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hc-header-subline {
    display: flex;
    align-items: center;
    min-height: 20px;
}

#hc-status,
.hc-status-text {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 0.86rem;
    color: rgba(255, 255, 255, 0.92);
    font-weight: 500;
    line-height: 1.2;
    min-height: 18px;
}

#hc-status::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: linear-gradient(135deg, #22c55e, #4ade80);
    box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.09);
    animation: hcPulse 2s infinite;
    flex-shrink: 0;
}

#hc-status.typing::before {
    background: linear-gradient(135deg, #f59e0b, #fbbf24);
    animation: hcTypingPulse 1s infinite;
}

@keyframes hcPulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.72;
        transform: scale(1.1);
    }
}

@keyframes hcTypingPulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.45;
        transform: scale(0.88);
    }
}

#hc-close {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    font-size: 1.45rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.22s ease, background 0.22s ease;
    flex-shrink: 0;
}

#hc-close:hover {
    background: rgba(255, 255, 255, 0.22);
    transform: rotate(90deg);
}

/* ===============================
   ADMIN BANNER
================================ */
.hc-admin-banner {
    display: none;
    align-items: center;
    gap: 9px;
    padding: 12px 16px;
    background: linear-gradient(135deg, #ecfdf5, #d1fae5);
    color: #065f46;
    font-size: 13px;
    font-weight: 700;
    border-bottom: 1px solid rgba(16, 185, 129, 0.18);
}

.hc-admin-banner-icon {
    font-size: 15px;
    flex-shrink: 0;
}

/* ===============================
   MESSAGE AREA
================================ */
#hc-messages,
.hc-messages {
    flex: 1;
    padding: 18px;
    background:
        radial-gradient(circle at top right, rgba(91, 109, 248, 0.06), transparent 28%),
        linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

#hc-messages::-webkit-scrollbar {
    width: 6px;
}

#hc-messages::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 999px;
}

#hc-messages::-webkit-scrollbar-thumb {
    background: rgba(91, 109, 248, 0.30);
    border-radius: 999px;
}

#hc-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(91, 109, 248, 0.46);
}

/* ===============================
   EMPTY STATE
================================ */
.hc-empty-state {
    margin: auto 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--hc-text-3);
    padding: 18px 12px;
}

.hc-empty-state-icon {
    width: 62px;
    height: 62px;
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.7rem;
    background: rgba(91, 109, 248, 0.08);
    color: var(--hc-primary-1);
    margin-bottom: 12px;
}

.hc-empty-state-title {
    font-size: 1rem;
    font-weight: 800;
    color: var(--hc-text-1);
    margin-bottom: 6px;
}

.hc-empty-state-text {
    font-size: 0.92rem;
    line-height: 1.55;
    max-width: 290px;
}

/* ===============================
   MESSAGE BUBBLES
================================ */
.hc-msg {
    max-width: 82%;
    padding: 13px 15px;
    border-radius: 18px;
    font-size: 0.95rem;
    line-height: 1.5;
    word-wrap: break-word;
    position: relative;
    animation: hcMsgIn 0.22s ease;
    box-shadow: var(--hc-shadow-soft);
}

@keyframes hcMsgIn {
    from {
        opacity: 0;
        transform: translateY(8px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.hc-user {
    align-self: flex-end;
    margin-left: auto;
    color: #fff;
    background: linear-gradient(135deg, var(--hc-primary-1) 0%, var(--hc-primary-2) 100%);
    border-bottom-right-radius: 8px;
    box-shadow:
        0 10px 22px rgba(91, 109, 248, 0.25),
        inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.hc-bot {
    align-self: flex-start;
    color: var(--hc-text-1);
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    border: 1px solid rgba(226, 232, 240, 0.9);
    border-bottom-left-radius: 8px;
}

.hc-system {
    align-self: center;
    max-width: 88%;
    text-align: center;
    font-size: 0.84rem;
    font-style: italic;
    color: #0f766e;
    background: linear-gradient(135deg, rgba(204, 251, 241, 0.92), rgba(153, 246, 228, 0.80));
    border: 1px solid rgba(20, 184, 166, 0.18);
    border-radius: 15px;
    padding: 9px 13px;
    box-shadow: none;
}

.hc-msg-meta {
    font-size: 12px;
    font-weight: 800;
    margin-bottom: 4px;
    color: #4f46e5;
}

.hc-user .hc-msg-meta {
    color: rgba(255, 255, 255, 0.95);
}

.hc-msg-body {
    font-size: 0.95rem;
    line-height: 1.55;
    color: inherit;
    white-space: pre-wrap;
    word-break: break-word;
}

.hc-msg-time {
    margin-top: 6px;
    font-size: 10.5px;
    opacity: 0.68;
}

.hc-user .hc-msg-time {
    color: rgba(255, 255, 255, 0.85);
}

/* ===============================
   START PANEL
================================ */
#hc-start,
.hc-start-panel {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 20px 18px;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    border-top: 1px solid rgba(226, 232, 240, 0.65);
}

.hc-start-head {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.hc-start-title {
    font-size: 1rem;
    font-weight: 800;
    color: var(--hc-text-1);
}

.hc-start-text {
    font-size: 0.9rem;
    color: var(--hc-text-3);
    line-height: 1.5;
}

.hc-field-wrap {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.hc-field-label {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--hc-text-2);
}

#hc-start input {
    width: 100%;
    padding: 13px 14px;
    border-radius: 14px;
    border: 1.5px solid rgba(203, 213, 225, 0.9);
    font-size: 0.95rem;
    color: var(--hc-text-1);
    background: rgba(255, 255, 255, 0.96);
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

#hc-start input:focus {
    border-color: rgba(91, 109, 248, 0.78);
    box-shadow: 0 0 0 4px rgba(91, 109, 248, 0.10);
    transform: translateY(-1px);
}

#hc-start input::placeholder {
    color: #94a3b8;
}

/* ===============================
   INPUT PANEL
================================ */
#hc-input,
.hc-input-panel {
    display: none;
    flex-direction: column;
    gap: 12px;
    padding: 16px 18px 18px;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    border-top: 1px solid rgba(226, 232, 240, 0.65);
}

.hc-message-input-wrap {
    display: flex;
    align-items: center;
}

#hc-text {
    width: 100%;
    padding: 14px 16px;
    border-radius: 16px;
    border: 1.5px solid rgba(203, 213, 225, 0.9);
    font-size: 0.95rem;
    color: var(--hc-text-1);
    background: rgba(255, 255, 255, 0.98);
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

#hc-text:focus {
    border-color: rgba(91, 109, 248, 0.78);
    box-shadow: 0 0 0 4px rgba(91, 109, 248, 0.10);
    transform: translateY(-1px);
}

#hc-text::placeholder {
    color: #94a3b8;
}

.hc-action-row {
    display: flex;
    gap: 10px;
}

.hc-primary-btn,
.hc-danger-btn,
#hc-start button,
#hc-send,
#hc-end {
    border: none;
    cursor: pointer;
    font-weight: 800;
    letter-spacing: -0.01em;
    transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.hc-primary-btn,
#hc-start button,
#hc-send {
    min-height: 46px;
    padding: 13px 18px;
    border-radius: 14px;
    color: #fff;
    background: linear-gradient(135deg, var(--hc-primary-1) 0%, var(--hc-primary-2) 100%);
    box-shadow:
        0 10px 22px rgba(91, 109, 248, 0.24),
        inset 0 1px 0 rgba(255, 255, 255, 0.16);
}

.hc-primary-btn:hover,
#hc-start button:hover,
#hc-send:hover {
    transform: translateY(-1px);
    box-shadow:
        0 14px 28px rgba(91, 109, 248, 0.32),
        inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.hc-danger-btn,
#hc-end {
    min-height: 46px;
    padding: 13px 18px;
    border-radius: 14px;
    color: #fff;
    background: linear-gradient(135deg, var(--hc-danger-1) 0%, var(--hc-danger-2) 100%);
    box-shadow:
        0 10px 20px rgba(239, 68, 68, 0.22),
        inset 0 1px 0 rgba(255, 255, 255, 0.14);
}

.hc-danger-btn:hover,
#hc-end:hover {
    transform: translateY(-1px);
    box-shadow:
        0 14px 26px rgba(239, 68, 68, 0.30),
        inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.hc-primary-btn:active,
.hc-danger-btn:active,
#hc-start button:active,
#hc-send:active,
#hc-end:active {
    transform: scale(0.98);
}

/* ===============================
   ACCESSIBILITY
================================ */
#hc-chat-bubble:focus,
#hc-close:focus,
#hc-start-btn:focus,
#hc-send:focus,
#hc-end:focus,
#hc-name:focus,
#hc-id:focus,
#hc-text:focus {
    outline: none;
}

/* ===============================
   MOBILE
================================ */
@media (max-width: 768px) {
    #hc-chat-bubble {
        right: 18px;
        bottom: 18px;
        width: 62px;
        height: 62px;
    }

    .hc-chat-bubble-icon {
        font-size: 1.55rem;
    }

    #hc-chat-box {
        right: 16px;
        bottom: 92px;
        width: calc(100vw - 32px);
        height: calc(100vh - 118px);
        max-height: none;
        border-radius: 22px;
    }

    .hc-header {
        padding: 16px;
    }

    .hc-header-avatar {
        width: 40px;
        height: 40px;
        border-radius: 12px;
    }

    #hc-messages {
        padding: 15px;
    }

    #hc-start,
    #hc-input {
        padding: 16px;
    }
}

@media (max-width: 480px) {
    #hc-chat-bubble {
        right: 14px;
        bottom: 14px;
        width: 58px;
        height: 58px;
    }

    #hc-chat-box {
        right: 10px;
        bottom: 82px;
        width: calc(100vw - 20px);
        height: calc(100vh - 96px);
        border-radius: 18px;
    }

    .hc-header {
        padding: 14px;
    }

    .hc-header-title {
        font-size: 0.95rem;
    }

    #hc-status {
        font-size: 0.81rem;
    }

    .hc-msg {
        max-width: 88%;
        padding: 11px 13px;
    }

    .hc-action-row {
        flex-direction: column;
    }

    #hc-send,
    #hc-end,
    .hc-primary-btn,
    .hc-danger-btn {
        width: 100%;
    }
}

/* ===============================
   DARK MODE
================================ */
body.dark-mode {
    --hc-bg-panel: rgba(20, 24, 36, 0.96);
    --hc-bg-panel-strong: #131826;
    --hc-bg-soft: #0f172a;
    --hc-text-1: #e5e7eb;
    --hc-text-2: #cbd5e1;
    --hc-text-3: #94a3b8;
    --hc-border: rgba(255, 255, 255, 0.08);
}

body.dark-mode #hc-chat-bubble {
    background: linear-gradient(135deg, #7c3aed 0%, #4f46e5 100%);
    box-shadow:
        0 14px 38px rgba(79, 70, 229, 0.40),
        0 6px 18px rgba(0, 0, 0, 0.32);
}

body.dark-mode .hc-chat-notify {
    border-color: #111827;
}

body.dark-mode #hc-chat-box {
    background: rgba(17, 24, 39, 0.96);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

body.dark-mode .hc-header {
    background: linear-gradient(135deg, #7c3aed 0%, #4f46e5 100%);
}

body.dark-mode .hc-admin-banner {
    background: linear-gradient(135deg, rgba(6, 78, 59, 0.95), rgba(5, 95, 70, 0.95));
    color: #a7f3d0;
    border-bottom: 1px solid rgba(16, 185, 129, 0.18);
}

body.dark-mode #hc-messages {
    background:
        radial-gradient(circle at top right, rgba(124, 58, 237, 0.10), transparent 28%),
        linear-gradient(135deg, #0f172a 0%, #111827 100%);
}

body.dark-mode .hc-empty-state-icon {
    background: rgba(124, 58, 237, 0.15);
    color: #c4b5fd;
}

body.dark-mode .hc-empty-state-title {
    color: #f3f4f6;
}

body.dark-mode .hc-bot {
    background: linear-gradient(135deg, #1f2937 0%, #111827 100%);
    color: #e5e7eb;
    border-color: rgba(255, 255, 255, 0.07);
}

body.dark-mode .hc-bot .hc-msg-meta {
    color: #c4b5fd;
}

body.dark-mode .hc-system {
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.92), rgba(15, 23, 42, 0.95));
    color: #93c5fd;
    border-color: rgba(59, 130, 246, 0.18);
}

body.dark-mode #hc-start,
body.dark-mode #hc-input {
    background: linear-gradient(180deg, #111827 0%, #0f172a 100%);
    border-top-color: rgba(255, 255, 255, 0.06);
}

body.dark-mode #hc-start input,
body.dark-mode #hc-text {
    background: rgba(255, 255, 255, 0.06);
    color: #e5e7eb;
    border-color: rgba(255, 255, 255, 0.10);
}

body.dark-mode #hc-start input::placeholder,
body.dark-mode #hc-text::placeholder {
    color: #94a3b8;
}

body.dark-mode #hc-start input:focus,
body.dark-mode #hc-text:focus {
    border-color: rgba(124, 58, 237, 0.72);
    box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.14);
}

body.dark-mode .hc-field-label,
body.dark-mode .hc-start-title,
body.dark-mode .hc-start-text {
    color: #cbd5e1;
}

/* ===============================
   PERFORMANCE / MOTION
================================ */
#hc-chat-bubble,
#hc-chat-box,
.hc-msg {
    will-change: transform, opacity;
}

@media (prefers-reduced-motion: reduce) {
    #hc-chat-bubble,
    #hc-chat-box,
    .hc-msg,
    #hc-start input,
    #hc-text,
    #hc-send,
    #hc-end,
    #hc-close {
        animation: none !important;
        transition: none !important;
    }
}