/* Support Chat Styles - Premium Redesign */
:root {
    --chat-primary: var(--primary-color);
    --chat-primary-rgb: var(--primary-rgb);
    --chat-secondary: var(--secondary-color);
    --chat-bg: var(--background-color);
    --chat-sent-bg: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    --chat-received-bg: var(--glass-bg);
    --chat-shadow: var(--shadow-lg);
}


.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: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-icon:hover {
    background: rgba(var(--chat-primary-rgb), 0.1);
    color: var(--chat-primary);
    transform: scale(1.1);
}

/* Chat Window - Modern Large Window */
.chat-window {
    background: var(--chat-bg);
    -webkit-backdrop-filter: blur(25px);
    backdrop-filter: blur(25px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 30px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 650px;
    width: 450px;
    max-width: 95vw;
    margin: 0 auto;
    box-shadow: var(--chat-shadow);
    transition: all 0.4s ease;
    position: relative;
}

.chat-window.full-page-chat {
    width: 100%;
    height: calc(100vh - 160px);
    max-width: 1200px;
    border-radius: 25px;
    margin-top: 10px;
}

@media (max-width: 768px) {
    .chat-window.full-page-chat {
        height: calc(100vh - 140px);
        border-radius: 0;
        margin-top: 0;
    }
}


.chat-header {
    background: linear-gradient(to bottom, rgba(var(--chat-primary-rgb), 0.1), transparent);
    padding: 20px 25px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.chat-header-avatar {
    width: 45px;
    height: 45px;
    border-radius: 15px;
    background: var(--chat-sent-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1rem;
    box-shadow: 0 4px 12px rgba(var(--chat-primary-rgb), 0.3);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 25px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    scroll-behavior: smooth;
    background: radial-gradient(circle at top right, rgba(var(--chat-primary-rgb), 0.03), transparent);
}

.message-bubble {
    max-width: 80%;
    padding: 12px 20px;
    border-radius: 20px;
    font-size: 0.85rem;
    position: relative;
    line-height: 1.5;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.03);
    transition: transform 0.2s ease;
}

.message-bubble:hover {
    transform: translateY(-2px);
}

.message-bubble.sent {
    align-self: flex-end;
    background: var(--chat-sent-bg);
    color: white;
    border-bottom-right-radius: 5px;
    box-shadow: 0 8px 20px rgba(var(--chat-primary-rgb), 0.2);
}

.message-bubble.received {
    align-self: flex-start;
    background: var(--chat-received-bg);
    color: var(--text-primary);
    border-bottom-left-radius: 5px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.message-time {
    position: absolute;
    font-size: 0.6rem;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s ease;
    bottom: -18px;
    white-space: nowrap;
    background: var(--chat-bg);
    padding: 2px 8px;
    border-radius: 10px;
    box-shadow: var(--shadow-sm);
    z-index: 10;
}

.message-bubble.sent .message-time {
    right: 5px;
    color: var(--text-secondary);
}

.message-bubble.received .message-time {
    left: 5px;
    color: var(--text-secondary);
}

.message-bubble.show-time .message-time {
    opacity: 1;
    transform: translateY(2px);
}

.message-bubble.sent .message-time {
    text-align: right;
}

.chat-input-area {
    padding: 20px 25px;
    background: rgba(255, 255, 255, 0.05);
    display: flex;
    gap: 15px;
    align-items: center;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.chat-input-wrapper {
    flex: 1;
    position: relative;
}

.chat-input {
    width: 100%;
    background: var(--chat-received-bg);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 18px;
    padding: 12px 20px;
    color: var(--text-primary);
    outline: none;
    font-size: 0.95rem;
    transition: all 0.3s;
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.02);
}

.chat-input:focus {
    border-color: var(--chat-primary);
    box-shadow: 0 0 0 4px rgba(var(--chat-primary-rgb), 0.1);
}

.chat-send-btn {
    background: var(--chat-sent-bg);
    color: white;
    border: none;
    width: 45px;
    height: 45px;
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 15px rgba(var(--chat-primary-rgb), 0.3);
}

.chat-send-btn:hover {
    transform: scale(1.1) rotate(-10deg);
    box-shadow: 0 8px 25px rgba(var(--chat-primary-rgb), 0.4);
}

/* Admin Specific - Premium Glassmorphism Redesign */
.chat-header-modern {
    background: linear-gradient(135deg, rgba(var(--chat-primary-rgb), 0.15), rgba(var(--chat-secondary-rgb), 0.05));
    padding: 20px 25px;
    border-bottom: 1px solid var(--glass-border);
    border-radius: 20px 20px 0 0;
}

.admin-chat-layout {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 20px;
    height: calc(100vh - 250px);
    min-height: 550px;
}

.chat-list-wrapper {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--glass-bg);
    border-radius: 20px;
}

.chat-list-search {
    padding: 15px 20px;
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-list-search i {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.chat-list-search input {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 0.9rem;
    width: 100%;
    outline: none;
}

.chat-list {
    flex: 1;
    overflow-y: auto;
}

.chat-list-item {
    padding: 15px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 15px;
    position: relative;
    border-right: 4px solid transparent;
}

.chat-list-item:hover {
    background: rgba(var(--chat-primary-rgb), 0.05);
    padding-right: 25px;
}

.chat-list-item.active {
    background: rgba(var(--chat-primary-rgb), 0.1);
    border-right-color: var(--chat-primary);
}

.chat-item-avatar {
    width: 48px;
    height: 48px;
    border-radius: 16px;
    background: linear-gradient(135deg, rgba(var(--chat-primary-rgb), 0.2), rgba(var(--chat-primary-rgb), 0.4));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: var(--text-primary);
    font-size: 1.1rem;
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
}

.chat-item-content {
    flex: 1;
    min-width: 0;
}

.chat-item-content h4 {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.95rem;
    margin-bottom: 4px;
}

.chat-item-last-msg {
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0;
}

.chat-item-time {
    font-size: 0.7rem;
    opacity: 0.6;
}

.unread-badge {
    background: var(--chat-primary);
    color: white;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    padding: 0 6px;
    box-shadow: 0 4px 10px rgba(var(--chat-primary-rgb), 0.3);
}

.chat-list-item.has-unread h4 {
    font-weight: 700;
}

.chat-list-item.has-unread .chat-item-last-msg {
    color: var(--text-primary);
    font-weight: 500;
}

.chat-detail-view {
    display: flex;
    flex-direction: column;
    border-radius: 20px;
    overflow: hidden;
    background: var(--glass-bg);
}

.empty-chat-icon {
    width: 100px;
    height: 100px;
    background: rgba(var(--chat-primary-rgb), 0.05);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    color: var(--chat-primary);
    margin-bottom: 25px;
    opacity: 0.5;
}

.chat-detail-header-mobile {
    padding: 15px 20px;
    background: var(--glass-bg);
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-header-avatar-small {
    width: 35px;
    height: 35px;
    border-radius: 10px;
    background: var(--chat-sent-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.9rem;
    font-weight: bold;
}

.chat-header-info-small {
    flex: 1;
}

/* 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-wrapper.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;
}

/* Status Indicator */
.status-dot {
    width: 8px;
    height: 8px;
    background: #2ecc71;
    border-radius: 50%;
    display: inline-block;
}

.status-dot.pulse {
    box-shadow: 0 0 0 rgba(46, 204, 113, 0.4);
    animation: statusPulse 2s infinite;
}

@keyframes statusPulse {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(46, 204, 113, 0.7);
    }

    70% {
        transform: scale(1);
        box-shadow: 0 0 0 6px rgba(46, 204, 113, 0);
    }

    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(46, 204, 113, 0);
    }
}

/* Animations */
@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.chat-window {
    animation: slideInUp 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.message-bubble {
    animation: slideInUp 0.3s ease-out;
}

/* Fix ordering and add more polish */
.chat-window {
    -webkit-backdrop-filter: blur(25px);
    backdrop-filter: blur(25px);
}

/* Role Badges */
.role-badge {
    font-size: 0.65rem;
    padding: 2px 8px;
    border-radius: 6px;
    font-weight: 600;
    text-transform: uppercase;
    display: inline-block;
}

.role-badge.seller {
    background: rgba(39, 174, 96, 0.1);
    color: #27ae60;
    border: 1px solid rgba(39, 174, 96, 0.2);
}

.role-badge.delivery {
    background: rgba(52, 152, 219, 0.1);
    color: #3498db;
    border: 1px solid rgba(52, 152, 219, 0.2);
}

.role-badge.buyer {
    background: rgba(155, 89, 182, 0.1);
    color: #9b59b6;
    border: 1px solid rgba(155, 89, 182, 0.2);
}

.message-role-label {
    display: block;
    font-size: 0.6rem;
    font-weight: 700;
    margin-bottom: 4px;
    opacity: 0.8;
}

.message-role-label.seller {
    color: #27ae60;
}

.message-role-label.delivery {
    color: #3498db;
}

.message-role-label.buyer {
    color: #9b59b6;
}