/* assets/css/chat-widget.css — Premium Chat Widget with Emoji, Reactions, Reply */

#chat-widget-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1050;
}

.chat-widget-trigger {
    width: 60px;
    height: 60px;
    background: var(--primary-color, #b40000);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    transition: all 0.3s ease;
    position: relative;
}

.chat-widget-trigger:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}

.unread-count-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background-color: #dc3545;
    color: white;
    font-size: 0.7rem;
    font-weight: bold;
    min-width: 22px;
    height: 22px;
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
}

.chat-widget-window {
    width: 370px;
    height: 500px;
    max-height: 80vh;
    background: white;
    border-radius: 15px;
    box-shadow: 0 5px 25px rgba(0,0,0,0.2);
    display: none; /* Hidden by default */
    flex-direction: column;
    overflow: hidden;
    position: absolute;
    bottom: 0;
    right: 0;
}
.chat-widget-window.open {
    display: flex; /* Show as flex when open */
}

.widget-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    flex-shrink: 0;
}

.widget-header h5 {
    font-size: 1rem;
    font-weight: 600;
}

.widget-body {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    position: relative;
}

.widget-conversations-list {
    overflow-y: auto;
    flex-grow: 1;
}

/* Conversation list items */
.widget-conversations-list .chat-list-item {
    display: flex;
    align-items: center;
    padding: 0.6rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid #e9ecef;
    transition: background-color 0.2s ease;
}

.widget-conversations-list .chat-list-item:hover {
    background-color: #f1f3f5;
}

.widget-conversations-list .chat-avatar,
.widget-messages-header .chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    margin-right: 0.75rem;
    flex-shrink: 0;
}

.widget-conversations-list .chat-list-item-info {
    flex-grow: 1;
    overflow: hidden;
}

.widget-conversations-list .chat-list-item-info h6 {
    margin-bottom: 0.1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.9rem;
    font-weight: 600;
}

.widget-conversations-list .chat-list-item-info p {
    font-size: 0.8rem;
    color: #6c757d;
    margin-bottom: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Messages view */
.widget-messages-view {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: white;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    transform: translateX(100%);
}

.widget-messages-view.active {
    transform: translateX(0);
}

.widget-messages-header {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #dee2e6;
    flex-shrink: 0;
}

.widget-messages-header .btn-back {
    border: none;
    background: none;
    font-size: 1rem;
    margin-right: 0.75rem;
    color: #6c757d;
    cursor: pointer;
}

.widget-messages-header h6 {
    font-size: 0.9rem;
    font-weight: 600;
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.widget-messages-header .btn-close {
    flex-shrink: 0;
    margin-left: 8px;
}

/* Messages area */
.widget-messages {
    flex-grow: 1;
    overflow-y: auto;
    padding: 0.75rem;
    background: #f1f3f5;
    min-height: 0;
}

/* Message wrapper - contains bubble + actions + reactions */
.widget-msg-wrap {
    display: flex;
    flex-direction: column;
    max-width: 82%;
    margin-bottom: 6px;
    position: relative;
}
.widget-msg-wrap.sent { align-self: flex-end; align-items: flex-end; margin-left: auto; }
.widget-msg-wrap.received { align-self: flex-start; align-items: flex-start; margin-right: auto; }

/* Reply quote inside bubble */
.widget-msg-reply {
    padding: 4px 8px;
    margin-bottom: 4px;
    border-radius: 8px;
    font-size: 0.72rem;
    border-left: 3px solid rgba(255,255,255,0.4);
    line-height: 1.3;
}
.widget-msg-wrap.sent .widget-msg-reply {
    background: rgba(255,255,255,0.15);
}
.widget-msg-wrap.received .widget-msg-reply {
    background: rgba(0,0,0,0.06);
    border-left-color: var(--primary-color, #b40000);
}
.widget-msg-reply__name {
    display: block;
    font-weight: 600;
    font-size: 0.68rem;
    margin-bottom: 1px;
}
.widget-msg-wrap.sent .widget-msg-reply__name { color: rgba(255,255,255,0.85); }
.widget-msg-wrap.received .widget-msg-reply__name { color: var(--primary-color, #b40000); }
.widget-msg-reply__text { display: block; opacity: 0.8; }

/* Message bubble */
.widget-msg-bubble {
    padding: 0.45rem 0.75rem;
    border-radius: 18px;
    font-size: 0.85rem;
    line-height: 1.4;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
    position: relative;
}
.widget-msg-wrap.sent .widget-msg-bubble {
    background: var(--primary-color, #b40000);
    color: white;
    border-bottom-right-radius: 4px;
}
.widget-msg-wrap.received .widget-msg-bubble {
    background-color: #e9ecef;
    color: #212529;
    border-bottom-left-radius: 4px;
}

.widget-msg-time {
    font-size: 0.6rem;
    opacity: 0.5;
    margin-top: 1px;
    display: block;
}
.widget-msg-wrap.sent .widget-msg-time { text-align: right; }
.widget-msg-wrap.received .widget-msg-time { text-align: left; }

/* Message hover actions (reply + react) */
.widget-msg-actions {
    display: none;
    gap: 2px;
    margin-bottom: 2px;
}
.widget-msg-wrap:hover .widget-msg-actions { display: flex; }
.widget-msg-wrap.sent .widget-msg-actions { flex-direction: row-reverse; }

.widget-msg-action-btn {
    width: 24px; height: 24px; border-radius: 50%; border: none;
    background: white; color: #6c757d; font-size: 0.65rem;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1); transition: all 0.15s ease;
}
.widget-msg-action-btn:hover { color: var(--primary-color, #b40000); background: #f8f9fa; }

/* Reactions display */
.widget-msg-reactions {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    margin-top: -2px;
    padding: 0 4px;
}

.widget-reaction-chip {
    display: inline-flex;
    align-items: center;
    gap: 1px;
    padding: 1px 5px;
    border-radius: 10px;
    border: 1px solid #dee2e6;
    font-size: 0.72rem;
    background: white;
    cursor: pointer;
    transition: all 0.15s ease;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.widget-reaction-chip:hover { border-color: var(--primary-color, #b40000); transform: scale(1.1); }
.widget-reaction-chip.mine { background: rgba(180, 0, 0, 0.08); border-color: var(--primary-color, #b40000); }
.widget-reaction-chip__count { font-size: 0.6rem; color: #6c757d; font-weight: 600; }

/* Floating reaction picker */
.widget-reaction-picker {
    position: fixed;
    z-index: 1060;
    display: none;
    background: white;
    border-radius: 20px;
    padding: 3px 4px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    border: 1px solid #dee2e6;
    gap: 1px;
    animation: widgetScaleIn 0.15s ease;
}

.widget-reaction-btn {
    border: none;
    background: none;
    font-size: 1.15rem;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 50%;
    transition: transform 0.15s ease;
    line-height: 1;
}
.widget-reaction-btn:hover { transform: scale(1.3); background: #f0f0f0; }

/* Reply bar */
.widget-reply-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    background: #f8f9fa;
    border-top: 1px solid #dee2e6;
    flex-shrink: 0;
    animation: widgetSlideUp 0.15s ease;
}
.widget-reply-bar__content { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; }
.widget-reply-bar__line { width: 3px; height: 28px; border-radius: 2px; background: var(--primary-color, #b40000); flex-shrink: 0; }
.widget-reply-bar__info { min-width: 0; }
.widget-reply-bar__name { display: block; font-size: 0.72rem; font-weight: 600; color: var(--primary-color, #b40000); }
.widget-reply-bar__text {
    display: block; font-size: 0.72rem; color: #6c757d;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px;
}
.widget-reply-bar__close {
    width: 24px; height: 24px; border-radius: 50%; border: none;
    background: transparent; color: #6c757d; cursor: pointer;
    display: flex; align-items: center; justify-content: center; font-size: 0.7rem;
    transition: all 0.15s ease;
}
.widget-reply-bar__close:hover { background: #e9ecef; color: #dc3545; }

/* Input area */
.widget-input-area {
    display: flex;
    align-items: center;
    padding: 0.4rem 0.5rem;
    border-top: 1px solid #dee2e6;
    flex-shrink: 0;
    gap: 2px;
}

.widget-emoji-toggle {
    border: none;
    background: none;
    color: var(--primary-color, #b40000);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 50%;
    transition: all 0.15s ease;
    flex-shrink: 0;
}
.widget-emoji-toggle:hover { transform: scale(1.1); }

.widget-input-area textarea {
    flex-grow: 1;
    border: none;
    resize: none;
    padding: 0.4rem 0.5rem;
    font-size: 0.85rem;
    background: transparent;
    max-height: 80px;
    font-family: inherit;
}

.widget-input-area textarea:focus {
    outline: none;
    box-shadow: none;
}

.widget-input-area #widget-send-btn {
    border: none;
    background: none;
    color: var(--primary-color, #b40000);
    font-size: 1.1rem;
    padding: 4px 6px;
    cursor: pointer;
    flex-shrink: 0;
}

/* Emoji picker */
.widget-emoji-picker {
    position: absolute;
    bottom: 44px;
    left: 4px;
    right: 4px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    border: 1px solid #dee2e6;
    z-index: 10;
    overflow: hidden;
    animation: widgetScaleIn 0.15s ease;
}

.widget-emoji-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 1px;
    padding: 6px;
    max-height: 160px;
    overflow-y: auto;
}
.widget-emoji-grid::-webkit-scrollbar { width: 4px; }
.widget-emoji-grid::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.1); border-radius: 2px; }

.widget-emoji-item {
    border: none;
    background: none;
    font-size: 1.15rem;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    transition: background 0.1s;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}
.widget-emoji-item:hover { background: #f0f0f0; }

/* Legacy compat: old .message classes still used */
.widget-messages .message {
    display: flex;
    margin-bottom: 0.75rem;
    max-width: 80%;
}

.widget-messages .message-bubble {
    padding: 0.5rem 0.85rem;
    border-radius: 18px;
    font-size: 0.9rem;
    line-height: 1.4;
    word-wrap: break-word;
}

.widget-messages .message.sent { margin-left: auto; }
.widget-messages .message.sent .message-bubble {
    background: var(--primary-color, #b40000);
    color: white;
}

.widget-messages .message.received { margin-right: auto; }
.widget-messages .message.received .message-bubble {
    background-color: #e9ecef;
    color: #212529;
}

/* Animations */
@keyframes widgetScaleIn { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }
@keyframes widgetSlideUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
