/* ==========================================
   Premium Live Chat CSS - Salas inspired
   ========================================== */

:root {
    --chat-primary: #2b509e;
    --chat-primary-light: rgba(43, 80, 158, 0.1);
    --chat-secondary: #4fb1e9;
    --chat-accent: #ffcc00;
    --chat-bg: rgba(255, 255, 255, 0.85);
    --chat-glass-border: rgba(43, 80, 158, 0.08);
    --chat-text-main: #0f172a;
    --chat-text-muted: #64748b;
    --chat-shadow: 0 10px 40px rgba(43, 80, 158, 0.15);
    --chat-radius: 20px;
}

[data-theme="dark"] {
    --chat-bg: rgba(15, 23, 42, 0.85);
    --chat-glass-border: rgba(255, 255, 255, 0.08);
    --chat-text-main: #f8fafc;
    --chat-text-muted: #94a3b8;
    --chat-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    --chat-primary-light: rgba(255, 255, 255, 0.05);
}

/* Floating Chat Trigger (Pulsing Bubble) */
.floating-chat-trigger {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--chat-primary), var(--chat-secondary));
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 30px rgba(43, 80, 158, 0.35);
    cursor: pointer;
    z-index: 9998;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    animation: chatBubbleFloat 3s ease-in-out infinite;
}

.floating-chat-trigger:hover {
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 12px 35px rgba(43, 80, 158, 0.5);
}

.floating-chat-trigger i {
    font-size: 24px;
    transition: transform 0.3s;
}

.floating-chat-trigger:hover i {
    transform: scale(1.15);
}

/* Unread Badge */
.floating-chat-trigger .chat-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff5252;
    color: white;
    font-size: 11px;
    font-weight: 800;
    min-width: 22px;
    height: 22px;
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    animation: chatBadgePop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Floating Chat Window (Glassmorphic) */
.floating-chat {
    position: fixed;
    bottom: 105px;
    right: 30px;
    width: 360px;
    height: 520px;
    background: var(--chat-bg);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border: 1px solid var(--chat-glass-border);
    border-radius: var(--chat-radius);
    box-shadow: var(--chat-shadow);
    display: flex;
    flex-direction: column;
    z-index: 9999;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.floating-chat.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Header */
.chat-header {
    background: linear-gradient(135deg, var(--chat-primary), var(--chat-secondary));
    color: white;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.chat-header-profile {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-avatar-char {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 16px;
    text-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.chat-header-info {
    display: flex;
    flex-direction: column;
}

.chat-title-name {
    font-weight: 800;
    font-size: 14px;
    letter-spacing: 0.3px;
    line-height: 1.2;
}

.chat-status {
    font-size: 10px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 4px;
}

.chat-status::before {
    content: '';
    width: 6px;
    height: 6px;
    background: #00ff66;
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 8px #00ff66;
}

.close-chat-btn {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(255,255,255,0.1);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.close-chat-btn:hover {
    background: rgba(255,255,255,0.2);
    transform: rotate(90deg);
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: transparent;
    scroll-behavior: smooth;
}

/* Scrollbar Customization */
.chat-messages::-webkit-scrollbar,
#admin-chat-list::-webkit-scrollbar,
.chat-history::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track,
#admin-chat-list::-webkit-scrollbar-track,
.chat-history::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb,
#admin-chat-list::-webkit-scrollbar-thumb,
.chat-history::-webkit-scrollbar-thumb {
    background: rgba(43, 80, 158, 0.15);
    border-radius: 10px;
}

.chat-messages::-webkit-scrollbar-thumb:hover,
#admin-chat-list::-webkit-scrollbar-thumb:hover,
.chat-history::-webkit-scrollbar-thumb:hover {
    background: rgba(43, 80, 158, 0.3);
}

/* Message Bubbles */
.msg-received, .msg-sent {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 13px;
    line-height: 1.45;
    word-wrap: break-word;
    position: relative;
    box-shadow: 0 2px 10px rgba(0,0,0,0.02);
    animation: chatMsgFadeIn 0.3s ease-out;
}

.msg-received {
    background: var(--chat-primary-light);
    color: var(--chat-text-main);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    border: 1px solid var(--chat-glass-border);
}

.msg-sent {
    background: linear-gradient(135deg, var(--chat-primary), var(--chat-secondary));
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 15px rgba(43, 80, 158, 0.15);
}

/* Attachments */
.msg-attachment-img {
    max-width: 100%;
    display: block;
    border-radius: 12px;
    margin-bottom: 6px;
    cursor: pointer;
    transition: transform 0.3s;
}

.msg-attachment-img:hover {
    transform: scale(1.02);
}

.msg-attachment-file {
    display: flex;
    align-items: center;
    gap: 8px;
    color: inherit;
    text-decoration: none;
    font-weight: 600;
    background: rgba(0, 0, 0, 0.05);
    padding: 8px 12px;
    border-radius: 10px;
    margin-bottom: 6px;
    font-size: 12px;
}

.msg-attachment-file:hover {
    background: rgba(0, 0, 0, 0.1);
}

.chat-name-form {
    display: none;
    flex-direction: column;
    align-items: center;
    padding: 24px 20px;
    text-align: center;
    background: var(--chat-bg);
    gap: 12px;
}

.chat-name-form.show {
    display: flex;
}

/* Admin Chat List inside widget */
.chat-user-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--chat-primary-light);
    border-radius: 12px;
    cursor: pointer;
    border: 1px solid var(--chat-glass-border);
    transition: all 0.2s;
    margin-bottom: 8px;
    animation: chatMsgFadeIn 0.3s ease-out;
}

.chat-user-item:hover {
    background: rgba(43, 80, 158, 0.15);
    border-color: var(--chat-primary);
    transform: translateY(-2px);
}

/* Chat Input Section */
.chat-input-area {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-top: 1px solid var(--chat-glass-border);
    background: rgba(255,255,255,0.02);
}

.chat-input-area input[type="text"] {
    flex: 1;
    border: 1px solid var(--chat-glass-border);
    background: rgba(255, 255, 255, 0.1);
    color: var(--chat-text-main);
    padding: 11px 16px;
    border-radius: 50px;
    outline: none;
    font-size: 13px;
    transition: all 0.3s;
}

.chat-input-area input[type="text"]:focus {
    border-color: var(--chat-primary);
    background: rgba(255, 255, 255, 0.2);
    box-shadow: 0 0 10px rgba(43, 80, 158, 0.1);
}

.chat-input-area button {
    background: linear-gradient(135deg, var(--chat-primary), var(--chat-secondary));
    color: white;
    border: none;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    box-shadow: 0 4px 10px rgba(43, 80, 158, 0.2);
}

.chat-input-area button:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 15px rgba(43, 80, 158, 0.3);
}

.chat-attach-btn {
    background: transparent !important;
    color: var(--chat-text-muted) !important;
    border: none;
    box-shadow: none !important;
    width: 32px !important;
    height: 32px !important;
    font-size: 16px !important;
}

.chat-attach-btn:hover {
    color: var(--chat-primary) !important;
    transform: scale(1.1) !important;
}

/* Animations */
@keyframes chatBubbleFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

@keyframes chatBadgePop {
    0% { transform: scale(0); }
    80% { transform: scale(1.15); }
    100% { transform: scale(1); }
}

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

/* Mobile responsive fixes */
@media (max-width: 480px) {
    .floating-chat {
        bottom: 0px !important;
        right: 0px !important;
        width: 100vw !important;
        height: 100% !important;
        border-radius: 0px !important;
        max-height: 100% !important;
    }
    
    .floating-chat-trigger {
        bottom: 15px;
        right: 15px;
        width: 50px;
        height: 50px;
    }
}

/* Tab Navigation for Logged In Chats (Salas/FB Inspired) */
.chat-tabs {
    display: flex;
    border-bottom: 1px solid var(--chat-glass-border);
    background: rgba(255, 255, 255, 0.03);
    padding: 8px 12px;
    gap: 8px;
    flex-shrink: 0;
}

.chat-tab {
    flex: 1;
    text-align: center;
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 700;
    color: var(--chat-text-muted);
    cursor: pointer;
    border-radius: 10px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.chat-tab:hover {
    color: var(--chat-text-main);
    background: rgba(43, 80, 158, 0.05);
}

.chat-tab.active {
    color: white;
    background: var(--chat-primary);
    box-shadow: 0 4px 10px rgba(43, 80, 158, 0.25);
}

