/* Premium Home Chat Widget Styles */
#home-chat-widget {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 9999;
    font-family: 'Outfit', 'Poppins', sans-serif;
    transition: bottom 0.3s cubic-bezier(0.165, 0.84, 0.44, 1);
}

#home-chat-widget.has-totop {
    bottom: 100px;
}


/* Chat Button */
.hc-widget-btn {
    width: 60px;
    height: 60px;
    background: #1e90ff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(30, 144, 255, 0.4);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s ease;
    border: none;
    outline: none;
    position: relative;
}

.hc-widget-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(30, 144, 255, 0.6);
}

.hc-widget-btn::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    background: inherit;
    border-radius: inherit;
    z-index: -1;
    animation: hc-pulse 2s infinite;
}

@keyframes hc-pulse {
    0% {
        transform: scale(1);
        opacity: 0.7;
    }

    100% {
        transform: scale(1.5);
        opacity: 0;
    }
}

/* Notification Dot */
.hc-notif-dot {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 14px;
    height: 14px;
    background: #ff4757;
    border: 2px solid #fff;
    border-radius: 50%;
    display: none;
    z-index: 5;
    box-shadow: 0 0 10px rgba(255, 71, 87, 0.5);
}

.hc-notif-dot.active {
    display: block;
    animation: hc-dot-bounce 0.5s ease infinite alternate;
}

@keyframes hc-dot-bounce {
    from {
        transform: translateY(0);
    }

    to {
        transform: translateY(-3px);
    }
}

/* Chat Window */
.hc-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    height: 550px;
    max-height: calc(100vh - 120px);
    background: rgba(255, 255, 255, .1);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px) scale(0.95);
    transform-origin: bottom right;
    transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
}

.hc-window.active {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

/* Header */
.hc-header {
    background: rgba(255, 255, 255, 0.027);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.027);
}

.hc-title {
    color: #fff;
    font-weight: 600;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.hc-status-dot {
    width: 8px;
    height: 8px;
    background: #00e676;
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 8px rgba(0, 230, 118, 0.6);
}

.hc-close {
    color: rgba(255, 255, 255, 0.6);
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    transition: color 0.2s;
}

.hc-close:hover {
    color: #fff;
}

/* Pinned Message Area */
.hc-pinned-container {
    background: rgba(255, 193, 7, 0.1);
    border-bottom: 1px solid rgba(255, 193, 7, 0.2);
    padding: 10px 15px;
    display: none;
    /* hidden by default */
    align-items: center;
    gap: 10px;
}

.hc-pinned-container.has-pin {
    display: flex;
}

.hc-pinned-icon {
    color: #ffc107;
    font-size: 14px;
}

.hc-pinned-content {
    flex: 1;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.9);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hc-pinned-close {
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    font-size: 12px;
}

.hc-pinned-close:hover {
    color: #ff4757;
}

/* Messages Area */
.hc-messages {
    flex: 1;
    padding: 20px 15px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* Custom Scrollbar for messages */
.hc-messages::-webkit-scrollbar {
    width: 5px;
}

.hc-messages::-webkit-scrollbar-track {
    background: transparent;
}

.hc-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 5px;
}

/* Individual Message */
.hc-msg {
    display: flex;
    gap: 10px;
    max-width: 90%;
    position: relative;
    word-break: break-word;
}

.hc-msg.mine {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.hc-msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    background: #000;
}

.hc-msg-content {
    background: #2d2e37;
    padding: 6px 10px;
    border-radius: 8px;
    position: relative;
    max-width: 100%;
    border: 1px solid rgba(255, 255, 255, 0.05);
    flex: 1;
}

.hc-msg.mine .hc-msg-content {
    background: #363742;
    /* Slightly lighter for own messages */
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: none;
}

.hc-msg-header {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 4px;
}

.hc-msg.mine .hc-msg-header {
    justify-content: flex-end;
}

.hc-msg-name {
    color: #ffb400;
    font-weight: 700;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.hc-msg-name::before {
    display: none;
    /* Strip extra icons */
}

.hc-msg.mine .hc-msg-name {
    color: #00e676;
    /* Greenish for mine just to differentiate nicely or keep theme */
}

.role-badge {
    font-size: 8px;
    padding: 0 3px;
    border-radius: 2px;
    text-transform: uppercase;
    font-weight: 800;
    display: inline-block;
    vertical-align: middle;
    margin-left: 5px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #fff;
}

.role-badge.mod {
    border-color: #1e90ff;
    color: #1e90ff;
}

.role-badge.admin {
    border-color: #ffc107;
    color: #ffc107;
}

.hc-msg.mine .role-badge {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.4);
}

.hc-msg-text {
    font-size: 13px;
    color: #eee;
    line-height: 1.4;
    margin-top: 4px;
    font-weight: 400;
    white-space: pre-wrap;
}


/* Replied Indicator */
.hc-replied-to {
    background: rgba(0, 0, 0, 0.2);
    border-left: 2px solid #aaa;
    padding: 4px 8px;
    border-radius: 3px;
    margin: 6px 0;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    box-orient: vertical;
}

.hc-msg.mine .hc-replied-to {
    border-left: 3px solid rgba(255, 255, 255, 0.6);
    background: rgba(0, 0, 0, 0.15);
}

.hc-msg-time {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.3);
    font-weight: 600;
}

.hc-msg-actions {
    display: flex;
    gap: 8px;
    font-size: 10px;
    font-weight: 600;
}


.hc-msg-action-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.4);
    cursor: pointer;
    font-family: inherit;
    padding: 0;
}

.hc-msg-action-btn:hover {
    color: #ff42a5;
    text-decoration: none;
}

.hc-msg.mine .hc-msg-actions {
    justify-content: flex-end;
    margin-right: 12px;
    margin-left: 0;
}

.hc-msg-action-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    font-size: 11px;
    cursor: pointer;
    padding: 0;
    transition: color 0.2s;
    font-family: inherit;
    font-weight: 600;
}

.hc-msg-action-btn:hover {
    color: #fff;
    text-decoration: underline;
}

.hc-msg-action-btn.delete:hover {
    color: #ff4757;
}

/* Input Area */
.hc-input-area {
    padding: 15px;
    background: rgba(255, 255, 255, 0.02);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Reply Context above input */
.hc-reply-context {
    display: none;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, .1);
    border-left: 3px solid #1e90ff;
    padding: 8px 12px;
    border-radius: 4px;
    margin-bottom: 5px;
    font-size: 12px;
}

.hc-reply-context.active {
    display: flex;
}

.hc-reply-text {
    color: rgba(255, 255, 255, 0.8);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 250px;
}

.hc-reply-text strong {
    color: #1e90ff;
    margin-right: 5px;
}

.hc-reply-close {
    cursor: pointer;
    color: rgba(255, 255, 255, 0.5);
}

.hc-reply-close:hover {
    color: #ff4757;
}

.hc-input-group {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.08);
    /* Minimal border */
    border-radius: 24px;
    padding: 4px 6px 4px 18px;
    transition: all 0.3s ease;
}

.hc-input-group:focus-within {
    border-color: rgba(30, 144, 255, 0.5);
    background: rgba(0, 0, 0, 0.4);
    box-shadow: 0 0 15px rgba(30, 144, 255, 0.1);
}

.hc-input {
    flex: 1;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 14px;
    padding: 10px 0;
    font-family: inherit;
    outline: none;
    resize: none;
    height: 40px;
    line-height: 20px;
}

.hc-send-btn {
    background: linear-gradient(135deg, #1e90ff, #0066ff);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 4px 12px rgba(30, 144, 255, 0.3);
}

.hc-send-btn:hover:not(:disabled) {
    transform: scale(1.1) translateX(2px);
    background: linear-gradient(135deg, #33a1ff, #1e90ff);
    box-shadow: 0 6px 15px rgba(30, 144, 255, 0.5);
}

.hc-send-btn:active:not(:disabled) {
    transform: scale(0.9);
}

.hc-send-btn:disabled {
    background: rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.2);
    cursor: not-allowed;
    box-shadow: none;
}

/* TOTOP Override */
#totop {
    width: 60px !important;
    height: 60px !important;
    bottom: 30px !important;
    right: 30px !important;
    background: #1e90ff !important;
    color: #fff !important;
    display: none;
    align-items: center;
    justify-content: center;
    border-radius: 50% !important;
    z-index: 9998 !important;
    box-shadow: 0 4px 15px rgba(30, 144, 255, 0.4) !important;
    opacity: 1 !important;
    transition: all 0.3s ease !important;
    border: none !important;
}

#totop.active {
    display: flex !important;
}

#totop:hover {
    transform: scale(1.1);
    background: #0b7dda !important;
}

#totop i {
    line-height: normal !important;
    font-size: 20px !important;
    color: #fff !important;
}

/* Responsive adjustments */
@media (max-width: 500px) {
    .hc-window {
        position: absolute;
        /* Follow widget position */
        width: 88vw;
        max-width: 340px;
        height: 450px;
        max-height: calc(100vh - 180px);
        bottom: 70px;
        right: 0;
        left: auto;
        top: auto;
        border-radius: 12px;
        z-index: 10001;
    }

    .hc-header {
        padding: 12px 15px;
        background: rgba(30, 31, 40, 0.9);
    }

    .hc-close {
        padding: 5px;
        font-size: 18px;
    }

    .hc-input-area {
        padding: 12px;
        background: rgba(30, 31, 40, 0.95);
    }

    .hc-widget-btn {
        width: 50px;
        height: 50px;
        font-size: 20px;
    }

    #home-chat-widget {
        bottom: 20px;
        right: 20px;
    }

    #home-chat-widget.has-totop {
        bottom: 80px;
        /* totop height(50) + bottom(20) + gap(10) */
    }

    #totop {
        width: 50px !important;
        height: 50px !important;
        bottom: 20px !important;
        right: 20px !important;
    }
}

/* Mention Notification */
.hc-mention-tag {
    background: #ff42a5;
    color: #fff;
    width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 10px;
    margin-left: 8px;
    box-shadow: 0 0 10px rgba(255, 66, 165, 0.4);
    animation: hc-mention-pulse 2s infinite;
}

@keyframes hc-mention-pulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }

    100% {
        transform: scale(1);
    }
}