/* Global Chat Widget Styles */

:root {
    --chat-bubble-size: 60px;
    --chat-modal-width: 400px;
    --chat-modal-height: 550px;
}

/* Floating Bubble */
.chat-widget-bubble {
    position: fixed;
    bottom: var(--space-xl);
    right: var(--space-xl);
    width: var(--chat-bubble-size);
    height: var(--chat-bubble-size);
    background: var(--color-brand);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 8px 32px rgba(99, 102, 241, 0.4);
    z-index: 10000;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    font-size: 1.5rem;
}

.chat-widget-bubble:hover {
    transform: scale(1.1) translateY(-5px);
    box-shadow: 0 12px 40px rgba(99, 102, 241, 0.5);
}

.chat-widget-bubble:active {
    transform: scale(0.95);
}

.chat-widget-bubble .unread-badge {
    position: absolute;
    top: 0;
    right: 0;
    background: var(--color-warning);
    color: var(--color-surface-900);
    font-size: 0.75rem;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    border: 2px solid white;
    margin-top: 10px;
    padding-top: 10px;
}

/* Tabs */
.chat-widget-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    background: var(--surface);
}

.chat-widget-tab {
    flex: 1;
    padding: 12px;
    text-align: center;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-muted);
    transition: all 0.2s;
    border-bottom: 2px solid transparent;
}

.chat-widget-tab.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
    background: rgba(var(--color-primary-rgb), 0.05);
}

.chat-widget-tab:hover:not(.active) {
    background: var(--bg-body);
}

/* Options Menu */
.chat-widget-options-menu {
    position: absolute;
    top: 60px;
    right: 15px;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    width: 180px;
    overflow: hidden;
    animation: fadeInScale 0.2s ease-out;
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-10px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.chat-widget-options-menu button {
    display: block;
    width: 100%;
    padding: 12px 16px;
    text-align: left;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-main);
    transition: background 0.2s;
}

.chat-widget-options-menu button:hover {
    background: var(--bg-body);
}

.chat-widget-options-menu button.text-danger {
    color: #dc3545;
}

.chat-widget-options-menu button.text-danger:hover {
    background: #fff5f5;
}

/* Chat Modal */
.chat-widget-modal {
    position: fixed;
    bottom: calc(var(--space-2xl) + var(--chat-bubble-size) + 10px);
    right: var(--space-xl);
    width: var(--chat-modal-width);
    height: var(--chat-modal-height);
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: var(--radius-2xl);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.1);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom right;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    opacity: 0;
    transform: scale(0.8) translateY(20px);
    pointer-events: none;
}

.chat-widget-modal.open {
    opacity: 1;
    transform: scale(1) translateY(0);
    pointer-events: all;
}

@media (max-width: 500px) {
    .chat-widget-modal {
        width: calc(100vw - 40px);
        height: calc(100vh - 120px);
        right: 20px;
        bottom: 90px;
    }
}

/* Chat Header */
.chat-widget-header {
    padding: var(--space-lg);
    background: rgba(255, 255, 255, 0.5);
    border-bottom: 1px solid var(--color-surface-100);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-widget-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
}

/* Scrollable Content */
.chat-widget-content {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

/* Conversation List Styled for Widget */
.widget-conv-list {
    padding: var(--space-md);
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.widget-conv-item {
    display: flex;
    gap: var(--space-md);
    padding: var(--space-md);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all 0.2s ease;
    background: white;
    border: 1px solid var(--color-surface-50);
}

.widget-conv-item:hover {
    background: var(--color-brand-50);
    border-color: var(--color-brand-100);
}

.widget-conv-item .avatar {
    width: 40px;
    height: 40px;
    font-size: 0.9rem;
}

/* Chat Area for Widget */
.widget-chat-area {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.widget-messages-container {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-md);
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    background: #f8fafc;
}

.widget-message-form {
    padding: var(--space-md);
    background: white;
    border-top: 1px solid var(--color-surface-100);
    display: flex;
    gap: var(--space-xs);
}

.widget-message-form input {
    flex: 1;
    padding: var(--space-sm) var(--space-md);
    border: 1px solid var(--color-surface-200);
    border-radius: var(--radius-full);
    outline: none;
    transition: border-color 0.2s;
}

.widget-message-form input:focus {
    border-color: var(--color-brand);
}

/* Animations */
@keyframes bubblePulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }

    100% {
        transform: scale(1);
    }
}

.chat-widget-bubble.has-unread {
    animation: bubblePulse 2s infinite ease-in-out;
}