/* ===============================
   CHAT FLOATING BUBBLE
================================ */
#hc-chat-bubble {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 68px;
    height: 68px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    cursor: pointer;
    z-index: 10000;
    box-shadow: 
        0 10px 30px rgba(102, 126, 234, 0.4),
        0 4px 12px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 2px solid rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

#hc-chat-bubble:hover {
    transform: scale(1.08) rotate(8deg);
    box-shadow: 
        0 15px 40px rgba(102, 126, 234, 0.5),
        0 6px 20px rgba(0, 0, 0, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

#hc-chat-bubble:active {
    transform: scale(0.95) rotate(-4deg);
}

/* ===============================
   CHAT BOX
================================ */
#hc-chat-box {
    position: fixed;
    bottom: 110px;
    right: 30px;
    width: 420px;
    height: 480px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 22px;
    box-shadow: 
        0 25px 50px -12px rgba(0, 0, 0, 0.25),
        0 0 0 1px rgba(255, 255, 255, 0.1);
    display: none;
    flex-direction: column;
    overflow: hidden;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    z-index: 10000;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    transform-origin: bottom right;
    animation: chatSlideIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes chatSlideIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ===============================
   HEADER
================================ */
.hc-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #ffffff;
    padding: 18px 20px;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
}

.hc-header span {
    font-size: 1rem;
    letter-spacing: -0.01em;
    display: flex;
    align-items: center;
    gap: 8px;
}

.hc-header button {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #ffffff;
    font-size: 1.5rem;
    cursor: pointer;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    backdrop-filter: blur(5px);
}

.hc-header button:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: rotate(90deg);
}

/* ===============================
   STATUS INDICATOR
================================ */
#hc-status {
    font-size: 0.85rem;
    margin-left: 12px;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 400;
    display: flex;
    align-items: center;
    gap: 6px;
    letter-spacing: -0.01em;
}

#hc-status::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: linear-gradient(135deg, #10b981, #34d399);
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.4);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { 
        opacity: 1; 
        transform: scale(1); 
    }
    50% { 
        opacity: 0.7; 
        transform: scale(1.1); 
    }
}

#hc-status.typing::before {
    background: linear-gradient(135deg, #f59e0b, #fbbf24);
    animation: typingPulse 1s infinite;
}

@keyframes typingPulse {
    0%, 100% { 
        opacity: 1; 
        transform: scale(1); 
    }
    50% { 
        opacity: 0.4; 
        transform: scale(0.9); 
    }
}

#hc-status.typing {
    animation: blink 1.5s infinite;
}

/* ===============================
   MESSAGES CONTAINER
================================ */
#hc-messages {
    flex: 1;
    padding: 20px;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

/* Custom scrollbar for messages */
#hc-messages::-webkit-scrollbar {
    width: 6px;
}

#hc-messages::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 10px;
}

#hc-messages::-webkit-scrollbar-thumb {
    background: rgba(102, 126, 234, 0.3);
    border-radius: 10px;
    transition: background 0.2s ease;
}

#hc-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(102, 126, 234, 0.5);
}

/* ===============================
   MESSAGE BASE
================================ */
.hc-msg {
    max-width: 80%;
    padding: 14px 18px;
    border-radius: 20px;
    font-size: 0.95rem;
    line-height: 1.5;
    word-wrap: break-word;
    animation: messageSlideIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ===============================
   USER MESSAGE (RIGHT)
================================ */
.hc-user {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #ffffff;
    align-self: flex-end;
    border-bottom-right-radius: 8px;
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    box-shadow: 
        0 4px 12px rgba(102, 126, 234, 0.3),
        0 2px 4px rgba(0, 0, 0, 0.1);
    margin-left: auto;
}

.hc-user::before {
    content: '';
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 8px;
    height: 8px;
    background: inherit;
    border-radius: 0 0 8px 0;
    clip-path: polygon(100% 0, 0 100%, 100% 100%);
}

/* ===============================
   ADMIN / BOT MESSAGE (LEFT)
================================ */
.hc-bot {
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    color: #1f2937;
    align-self: flex-start;
    border-bottom-left-radius: 8px;
    border-top-right-radius: 20px;
    border-top-left-radius: 20px;
    box-shadow: 
        0 4px 12px rgba(0, 0, 0, 0.08),
        0 2px 4px rgba(0, 0, 0, 0.05),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(229, 231, 235, 0.5);
}

.hc-bot::before {
    content: '';
    position: absolute;
    bottom: -2px;
    left: -2px;
    width: 8px;
    height: 8px;
    background: inherit;
    border-radius: 0 0 0 8px;
    clip-path: polygon(0 0, 0 100%, 100% 100%);
}

/* ===============================
   SYSTEM MESSAGE (CENTER)
================================ */
.hc-system {
    align-self: center;
    background: linear-gradient(135deg, rgba(224, 242, 254, 0.9), rgba(186, 230, 253, 0.9));
    color: #0369a1;
    font-style: italic;
    font-size: 0.85rem;
    text-align: center;
    border-radius: 16px;
    padding: 10px 16px;
    max-width: 85%;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(14, 165, 233, 0.2);
    box-shadow: 0 2px 8px rgba(14, 165, 233, 0.15);
    letter-spacing: -0.01em;
}

/* ===============================
   START FORM
================================ */
#hc-start {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    backdrop-filter: blur(10px);
}

#hc-start input {
    padding: 14px 16px;
    border-radius: 14px;
    border: 2px solid rgba(209, 213, 219, 0.5);
    font-size: 0.95rem;
    background: rgba(255, 255, 255, 0.9);
    transition: all 0.2s ease;
    color: #1f2937;
    outline: none;
    backdrop-filter: blur(5px);
}

#hc-start input:focus {
    border-color: #667eea;
    box-shadow: 
        0 0 0 3px rgba(102, 126, 234, 0.1),
        0 2px 4px rgba(0, 0, 0, 0.05);
    transform: translateY(-1px);
    background: white;
}

#hc-start input::placeholder {
    color: #9ca3af;
    opacity: 0.7;
}

#hc-start button {
    padding: 14px;
    border-radius: 14px;
    border: none;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #ffffff;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 
        0 4px 12px rgba(102, 126, 234, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    letter-spacing: -0.01em;
}

#hc-start button:hover {
    transform: translateY(-2px);
    box-shadow: 
        0 8px 20px rgba(102, 126, 234, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

#hc-start button:active {
    transform: translateY(0);
}

/* ===============================
   MESSAGE INPUT
================================ */
#hc-input {
    padding: 20px;
    display: none;
    gap: 12px;
    align-items: center;
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    border-top: 1px solid rgba(229, 231, 235, 0.6);
    backdrop-filter: blur(10px);
}

#hc-input input {
    flex: 1;
    padding: 14px 18px;
    border-radius: 18px;
    border: 2px solid rgba(209, 213, 219, 0.5);
    font-size: 0.95rem;
    color: #1f2937;
    background: rgba(255, 255, 255, 0.9);
    outline: none;
    transition: all 0.2s ease;
    backdrop-filter: blur(5px);
}

#hc-input input:focus {
    border-color: #667eea;
    box-shadow: 
        0 0 0 3px rgba(102, 126, 234, 0.1),
        0 2px 4px rgba(0, 0, 0, 0.05);
    background: white;
}

#hc-input input::placeholder {
    color: #9ca3af;
    opacity: 0.7;
}

#hc-input button {
    padding: 14px 20px;
    border-radius: 18px;
    border: none;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #ffffff;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
    box-shadow: 
        0 4px 12px rgba(102, 126, 234, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    letter-spacing: -0.01em;
    min-width: 80px;
}

#hc-input button:hover {
    transform: translateY(-2px);
    box-shadow: 
        0 8px 20px rgba(102, 126, 234, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

#hc-input button:active {
    transform: translateY(0);
}

#hc-end {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%) !important;
    box-shadow: 
        0 4px 12px rgba(239, 68, 68, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.2) !important;
}

#hc-end:hover {
    box-shadow: 
        0 8px 20px rgba(239, 68, 68, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.3) !important;
}

/* ===============================
   DARK MODE CHAT STYLES
================================ */
body.dark-mode #hc-chat-bubble {
    background: linear-gradient(135deg, #8a2be2 0%, #4a00e0 100%);
    border: 2px solid rgba(255, 255, 255, 0.1);
    box-shadow: 
        0 10px 30px rgba(138, 43, 226, 0.4),
        0 4px 12px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

body.dark-mode #hc-chat-box {
    background: rgba(30, 30, 40, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 
        0 25px 50px -12px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(255, 255, 255, 0.05);
}

body.dark-mode .hc-header {
    background: linear-gradient(135deg, #8a2be2 0%, #4a00e0 100%);
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

body.dark-mode #hc-messages {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

body.dark-mode #hc-messages::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

body.dark-mode #hc-messages::-webkit-scrollbar-thumb {
    background: rgba(138, 43, 226, 0.4);
}

body.dark-mode #hc-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(138, 43, 226, 0.6);
}

body.dark-mode .hc-user {
    background: linear-gradient(135deg, #8a2be2 0%, #4a00e0 100%);
    box-shadow: 
        0 4px 12px rgba(138, 43, 226, 0.4),
        0 2px 4px rgba(0, 0, 0, 0.2);
}

body.dark-mode .hc-bot {
    background: linear-gradient(135deg, #2d2d3d 0%, #252536 100%);
    color: #e5e7eb;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 
        0 4px 12px rgba(0, 0, 0, 0.3),
        0 2px 4px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

body.dark-mode .hc-system {
    background: linear-gradient(135deg, rgba(30, 58, 138, 0.9), rgba(49, 46, 129, 0.9));
    color: #93c5fd;
    border: 1px solid rgba(59, 130, 246, 0.3);
    box-shadow: 0 2px 8px rgba(30, 64, 175, 0.3);
}

body.dark-mode #hc-start {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

body.dark-mode #hc-start input {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
    color: #e5e7eb;
}

body.dark-mode #hc-start input:focus {
    background: rgba(255, 255, 255, 0.12);
    border-color: #8a2be2;
    box-shadow: 0 0 0 3px rgba(138, 43, 226, 0.2);
}

body.dark-mode #hc-start input::placeholder {
    color: #9ca3af;
}

body.dark-mode #hc-start button,
body.dark-mode #hc-input button {
    background: linear-gradient(135deg, #8a2be2 0%, #4a00e0 100%);
    box-shadow: 
        0 4px 12px rgba(138, 43, 226, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

body.dark-mode #hc-input {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border-top-color: rgba(255, 255, 255, 0.1);
}

body.dark-mode #hc-input input {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
    color: #e5e7eb;
}

body.dark-mode #hc-input input:focus {
    background: rgba(255, 255, 255, 0.12);
    border-color: #8a2be2;
    box-shadow: 0 0 0 3px rgba(138, 43, 226, 0.2);
}

/* ===============================
   MOBILE RESPONSIVE
================================ */
@media (max-width: 768px) {
    #hc-chat-box {
        width: calc(100vw - 40px);
        height: calc(100vh - 140px);
        max-height: 600px;
        right: 20px;
        bottom: 100px;
        border-radius: 20px;
    }
    
    #hc-chat-bubble {
        right: 20px;
        bottom: 20px;
        width: 60px;
        height: 60px;
        font-size: 1.6rem;
    }
    
    .hc-header {
        padding: 16px 18px;
    }
    
    #hc-messages {
        padding: 16px;
    }
    
    .hc-msg {
        padding: 12px 16px;
        max-width: 85%;
    }
    
    #hc-start,
    #hc-input {
        padding: 20px;
    }
}

@media (max-width: 480px) {
    #hc-chat-box {
        width: calc(100vw - 32px);
        height: calc(100vh - 120px);
        right: 16px;
        bottom: 90px;
        border-radius: 18px;
    }
    
    #hc-chat-bubble {
        right: 16px;
        bottom: 16px;
        width: 56px;
        height: 56px;
        font-size: 1.5rem;
    }
    
    .hc-header {
        padding: 14px 16px;
    }
    
    .hc-header span {
        font-size: 0.9rem;
    }
    
    #hc-messages {
        padding: 14px;
        gap: 10px;
    }
    
    .hc-msg {
        padding: 10px 14px;
        font-size: 0.9rem;
        max-width: 88%;
    }
    
    .hc-system {
        font-size: 0.8rem;
        padding: 8px 12px;
    }
    
    #hc-start,
    #hc-input {
        padding: 16px;
        gap: 12px;
    }
    
    #hc-start input,
    #hc-input input {
        padding: 12px 14px;
        font-size: 0.9rem;
    }
    
    #hc-start button,
    #hc-input button {
        padding: 12px 16px;
        font-size: 0.9rem;
    }
}

/* ===============================
   ANIMATIONS
================================ */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes blink {
    0%, 100% { 
        opacity: 1; 
    }
    50% { 
        opacity: 0.6; 
    }
}

/* ===============================
   TYPING ANIMATION
================================ */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: currentColor;
    border-radius: 50%;
    opacity: 0.6;
    animation: typingBounce 1.4s infinite;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingBounce {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.6;
    }
    30% {
        transform: translateY(-4px);
        opacity: 1;
    }
}

/* ===============================
   SMOOTH TRANSITIONS
================================ */
#hc-chat-box,
.hc-msg,
#hc-start input,
#hc-input input,
#hc-start button,
#hc-input button {
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===============================
   ACCESSIBILITY
================================ */
#hc-chat-bubble:focus,
#hc-start button:focus,
#hc-input button:focus,
.hc-header button:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

body.dark-mode #hc-chat-bubble:focus,
body.dark-mode #hc-start button:focus,
body.dark-mode #hc-input button:focus,
body.dark-mode .hc-header button:focus {
    outline-color: #8a2be2;
}

/* ===============================
   PERFORMANCE OPTIMIZATIONS
================================ */
#hc-chat-bubble,
#hc-chat-box {
    will-change: transform, opacity;
    contain: layout style paint;
}

.hc-msg {
    will-change: transform, opacity;
    
    
}

/* ===============================
   UNREAD NOTIFICATION BADGE
================================ */
.hc-chat-notify {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 20px;
    height: 20px;
    background: #ef4444;
    color: #ffffff;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

/* ===============================
   ADMIN BANNER
================================ */
.hc-admin-banner {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: linear-gradient(135deg, #ecfdf5, #d1fae5);
    color: #065f46;
    font-size: 13px;
    font-weight: 600;
    border-bottom: 1px solid rgba(16, 185, 129, 0.2);
}

.hc-admin-banner-icon {
    font-size: 16px;
}

/* ===============================
   MESSAGE META (NAME / ROLE)
================================ */
.hc-msg-meta {
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 4px;
    color: #4b5563;
}

/* ===============================
   MESSAGE TIME
================================ */
.hc-msg-time {
    font-size: 10px;
    margin-top: 4px;
    opacity: 0.6;
}

/* ===============================
   ADMIN MESSAGE STYLE BOOST
================================ */
.hc-bot .hc-msg-meta {
    color: #4f46e5;
    font-weight: 700;
}

/* ===============================
   DARK MODE SUPPORT (NEW ITEMS)
================================ */
body.dark-mode .hc-admin-banner {
    background: linear-gradient(135deg, #064e3b, #065f46);
    color: #a7f3d0;
    border-bottom: 1px solid rgba(16, 185, 129, 0.3);
}

body.dark-mode .hc-msg-meta {
    color: #cbd5f5;
}

body.dark-mode .hc-chat-notify {
    background: #ef4444;
}