/* Support Chat Styles */
:root {
    --chat-primary: var(--primary-color, #FF6B35);
    --chat-bg: var(--glass-bg, rgba(255, 255, 255, 0.1));
    --chat-sent-bg: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    --chat-received-bg: rgba(255, 255, 255, 0.08);
}

.flex-align {
    display: flex;
    align-items: center;
}

.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 1.2rem;
    cursor: pointer;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.1);
}

.dark-mode {
    --chat-received-bg: rgba(255, 255, 255, 0.05);
}

/* Chat Window - Shared */
.chat-window {
    background: var(--glass-bg);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 550px;
    width: 380px;
    max-width: 95vw;
    margin: 0 auto;
    box-shadow: var(--shadow-lg);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}

.message-bubble {
    max-width: 75%;
    padding: 10px 16px;
    border-radius: 18px;
    font-size: 0.9rem;
    position: relative;
    line-height: 1.4;
    box-shadow: none;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.message-bubble.sent {
    align-self: flex-end;
    background: var(--chat-sent-bg);
    color: white;
    border-bottom-right-radius: 4px;
}

.message-bubble.received {
    align-self: flex-start;
    background: var(--chat-received-bg);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
    border: none;
}

.message-time {
    display: block;
    font-size: 0.65rem;
    opacity: 0.5;
    text-align: left;
    margin-top: 2px;
}

.message-bubble.sent .message-time {
    color: rgba(255, 255, 255, 0.7);
    text-align: right;
}

.chat-input-area {
    padding: 12px 15px;
    background: rgba(0, 0, 0, 0.02);
    display: flex;
    gap: 10px;
    align-items: center;
    border-top: 1px solid var(--glass-border);
}

.chat-input {
    flex: 1;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 8px 15px;
    color: var(--text-primary);
    outline: none;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.chat-input:focus {
    border-color: var(--primary-color);
    background: var(--card-color);
}

.chat-send-btn {
    background: transparent;
    color: var(--primary-color);
    border: none;
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.3rem;
    transition: all 0.2s;
}

.chat-send-btn:hover {
    transform: scale(1.15) rotate(-10deg);
    color: var(--primary-dark);
}

/* Admin Specific */
.admin-chat-layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 20px;
    height: 70vh;
    min-height: 500px;
}

.chat-list {
    background: var(--glass-bg);
    border-radius: 15px;
    overflow-y: auto;
    border: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
}

.chat-list-item {
    padding: 18px;
    border-bottom: 1px solid var(--glass-border);
    cursor: pointer;
    transition: all 0.2s;
    border-right: 4px solid transparent;
}

.chat-list-item:hover {
    background: rgba(var(--primary-rgb), 0.05);
}

.chat-list-item.active {
    background: rgba(var(--primary-rgb), 0.1);
    border-right-color: var(--primary-color);
}

.chat-list-item h4 {
    margin: 0 0 6px 0;
    font-size: 1rem;
    color: var(--text-primary);
}

.chat-list-item p {
    margin: 0;
    font-size: 0.85rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-detail-view {
    display: flex;
    flex-direction: column;
    border-radius: 15px;
    overflow: hidden;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
}

/* Mobile Adjustments */
.mobile-only {
    display: none;
}

@media (max-width: 768px) {
    .admin-chat-layout {
        grid-template-columns: 1fr;
        height: calc(100vh - 140px);
        gap: 0;
    }

    .chat-list.mobile-hidden {
        display: none;
    }

    .chat-detail-view {
        display: none;
    }

    .chat-detail-view.mobile-visible {
        display: flex;
        position: fixed;
        top: 60px;
        left: 0;
        right: 0;
        bottom: 80px;
        z-index: 1000;
        border-radius: 0;
        border: none;
    }

    .mobile-only {
        display: flex;
    }

    .mobile-full-chat {
        flex: 1 !important;
    }

    /* Adjust customer chat window when in modal */
    .mobile-chat-modal {
        width: 100% !important;
        max-width: 100% !important;
        height: calc(100vh - 140px) !important;
        max-height: calc(100vh - 140px) !important;
        border-radius: 0 !important;
        position: fixed !important;
        top: 60px !important;
        bottom: 80px !important;
        left: 0 !important;
        right: 0 !important;
        margin: 0 !important;
        z-index: 1300 !important;
        padding: 0 !important;
        gap: 0 !important;
    }

    .mobile-chat-modal .chat-window {
        width: 100% !important;
        height: 100% !important;
        border-radius: 0 !important;
        border: none !important;
    }

    /* Ensure messages container takes full space */
    .chat-messages {
        flex: 1;
        overflow-y: auto;
    }

    /* Adjust header in mobile detailed view */
    .in-chat #adminChatHeaderContainer {
        display: none;
    }
}

/* Empty State */
.empty-chat-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

.empty-chat-state i {
    font-size: 4rem;
    margin-bottom: 20px;
    opacity: 0.3;
}

/* Animations */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-bubble {
    animation: slideIn 0.3s ease-out;
}