/* public/widget.css */
#chat-widget {
    position: fixed;
    top: auto;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
}

.chat-widget-small{
    width: 30px;
    height: 30px;
    left: 60%;
}

/* Пузырёк */
.cw-bubble {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #007bff, #6610f2);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    /* font-size: 28px; */
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(0, 123, 255, 0.4);
    position: relative;
    transition: all 0.3s;
    user-select: none;
}

.cw-bubble:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 24px rgba(0, 123, 255, 0.6);
}

.cw-bubble.hidden {
    display: none;
}

.cw-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #dc3545;
    color: white;
    border-radius: 50%;
    min-width: 24px;
    height: 24px;
    padding: 0 6px;
    font-size: 12px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
}

/* Контейнер */
.cw-container {
    width: 320px;
    height: 550px;
    max-height: calc(100vh - 40px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: cw-slide-up 0.3s ease-out;
}

.cw-container.open {
    display: flex;
}

@keyframes cw-slide-up {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* Заголовок */
.cw-header {
    background: linear-gradient(135deg, #007bff, #6610f2);
    color: white;
    padding: 14px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cw-header-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.cw-status {
    font-size: 11px;
    opacity: 0.8;
}

.cw-status.online {             
            color: #24f111; 
        }
.cw-status.offline { 
            color: #f73636; 
        }
.cw-status.oonline {             
            display: inline-block;
            width: 8px;
            height: 8px;
            background: #28a745;
            border-radius: 50%;
            margin-right: 4px; 
            color: #17a30a; 
        }
.cw-status.ooffline { 
            display: inline-block;
            width: 8px;
            height: 8px;
            background: #aaa;
            border-radius: 50%;
            margin-right: 4px;
            color: #d32d2d; 
        }

.cw-minimize {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cw-minimize:hover { background: rgba(255,255,255,0.3); }

/* Табы */
.cw-tabs {
    display: flex;
    border-bottom: 1px solid #e9ecef;
    background: #f8f9fa;
}

.cw-tab {
    flex: 1;
    padding: 10px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    font-weight: 500;
    color: #6c757d;
    transition: all 0.2s;
}

.cw-tab.active {
    color: #007bff;
    border-bottom-color: #007bff;
    background: white;
}

.cw-tab-content {
    display: none;
    flex: 1;
    flex-direction: column;
    overflow: hidden;
}

.cw-tab-content.active {
    display: flex;
}

/* Список диалогов */
.cw-conversations {
    flex: 1;
    overflow-y: auto;
}

.cw-conv {
    padding: 12px 16px;
    border-bottom: 1px solid #f1f3f5;
    cursor: pointer;
    transition: background 0.15s;
}

.cw-conv:hover { background: #f8f9fa; }
.cw-conv.active { background: #e7f1ff; }

.cw-conv-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.cw-conv-header strong {
    color: #212529;
    font-size: 14px;
}

.cw-conv-badge {
    background: #dc3545;
    color: white;
    border-radius: 10px;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: bold;
}

.cw-conv-ad {
    font-size: 12px;
    color: #6c757d;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cw-conv-preview {
    font-size: 13px;
    color: #6c757d;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cw-empty, .cw-loading, .cw-error {
    padding: 40px 20px;
    text-align: center;
    color: #6c757d;
}

.cw-error { color: #dc3545; }

/* Чат */
.cw-chat-header {
    padding: 10px 16px;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    font-weight: 500;
}

.cw-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    background: #f8f9fa;
}

.cw-msg {
    display: flex;
    flex-direction: column;
    margin-bottom: 8px;
}

.cw-msg-me { align-items: flex-end; }
.cw-msg-them { align-items: flex-start; }

.cw-msg .cw-bubble {
    max-width: 75%;
    padding: 8px 12px;
    border-radius: 16px;
    word-wrap: break-word;
    line-height: 1.4;
}

.cw-msg-me .cw-bubble {
    background: #007bff;
    color: white;
    border-bottom-right-radius: 4px;
}

.cw-msg-them .cw-bubble {
    background: white;
    color: #212529;
    border-bottom-left-radius: 4px;
    border: 1px solid #e9ecef;
}

.cw-meta {
    font-size: 10px;
    color: #999;
    margin-top: 2px;
    display: flex;
    gap: 4px;
    align-items: center;
}

.cw-typing {
    padding: 6px 12px;
    font-size: 12px;
    color: #6c757d;
    font-style: italic;
}

/* Форма ввода */
.cw-input-form {
    display: flex;
    padding: 10px;
    gap: 8px;
    background: white;
    border-top: 1px solid #e9ecef;
}

.cw-input-form input {
    flex: 1;
    padding: 8px 14px;
    border: 1px solid #ced4da;
    border-radius: 20px;
    outline: none;
    font-size: 14px;
}

.cw-input-form input:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0,123,255,0.1);
}

.cw-input-form button {
    background: #007bff;
    color: white;
    border: none;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.cw-input-form button:hover { background: #0056b3; }

/* Скроллбар */
.cw-conversations::-webkit-scrollbar,
.cw-messages::-webkit-scrollbar {
    width: 6px;
}

.cw-conversations::-webkit-scrollbar-thumb,
.cw-messages::-webkit-scrollbar-thumb {
    background: #ced4da;
    border-radius: 3px;
}

/* Мобильная адаптация */
@media (max-width: 480px) {
    .chat-widget-small{
        width: 50px;
        height: 50px;
        left: 85%;
    }
    .chat-widget {
        bottom: 10px;
        right: 10px;
        left: 10px;
    }
    
    .cw-container {
        /* width: 100%; */
        height: calc(90vh - 20px);
        max-height: none;
    }
}

/* Тёмная тема */
[data-bs-theme="dark"] #chat-widget .cw-container {
    background: #1e1e1e;
    color: #e9ecef;
}

[data-bs-theme="dark"] .cw-conv:hover { background: #2d2d2d; }
[data-bs-theme="dark"] .cw-conv.active { background: #1a3a5c; }
[data-bs-theme="dark"] .cw-conv-header strong { color: #e9ecef; }
[data-bs-theme="dark"] .cw-tabs { background: #2d2d2d; border-bottom-color: #444; }
[data-bs-theme="dark"] .cw-tab { color: #adb5bd; }
[data-bs-theme="dark"] .cw-tab.active { background: #1e1e1e; color: #6ea8fe; }
[data-bs-theme="dark"] .cw-messages { background: #121212; }
[data-bs-theme="dark"] .cw-msg-them .cw-bubble { background: #2d2d2d; color: #e9ecef; border-color: #444; }
[data-bs-theme="dark"] .cw-input-form { background: #1e1e1e; border-top-color: #444; }
[data-bs-theme="dark"] .cw-input-form input { background: #2d2d2d; color: #e9ecef; border-color: #444; }
[data-bs-theme="dark"] .cw-chat-header { background: #2d2d2d; border-bottom-color: #444; }