/* Support Chat - Premium Kyne Design */
:root {
    --chat-primary: #6366f1;
    --chat-primary-gradient: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    --chat-bg: #f8fafc;
    --chat-sidebar-bg: rgba(255, 255, 255, 0.8);
    --chat-border: rgba(226, 232, 240, 0.8);
    --chat-text-main: #1e293b;
    --chat-text-muted: #64748b;
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.4);
}

.support-page {
    padding: 0;
    height: 80vh;
    display: flex;
    overflow: hidden;
}

.chat-container {
    display: grid;
    grid-template-columns: 320px 1fr;
    width: 100%;
    height: 100%;
    background: var(--chat-sidebar-bg);
    border-radius: 20px;
    overflow: hidden;
    border: 1px solid var(--chat-border);
    backdrop-filter: blur(12px);
    position: relative;
}

/* Sidebar */
.chat-sidebar {
    border-right: 1px solid var(--chat-border);
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.sidebar-header {
    padding: 16px 20px 10px 20px;
    background: var(--glass-bg);
    border-bottom: 1px solid var(--chat-border);
}

.sidebar-filters {
    display: flex;
    gap: 6px;
    margin-top: 12px;
    overflow-x: auto;
    padding-bottom: 8px;
    scrollbar-width: thin;
    scrollbar-color: #e2e8f0 transparent;
}

.sidebar-filters::-webkit-scrollbar {
    height: 4px;
}

.sidebar-filters::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-filters::-webkit-scrollbar-thumb {
    background-color: #e2e8f0;
    border-radius: 10px;
}

.sidebar-filters::-webkit-scrollbar-thumb:hover {
    background-color: #cbd5e1;
}

.filter-tab {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid #e2e8f0;
    background: #fff;
    color: #64748b;
}

.filter-tab:hover {
    background: #f1f5f9;
    color: var(--chat-primary);
}

.filter-tab.active {
    background: var(--chat-primary-gradient);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 4px 10px -2px rgba(99, 102, 241, 0.3);
}

.header-top h5 {
    margin: 0 0 12px 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--chat-text-main);
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-top h5 i {
    color: var(--chat-primary);
}

.search-container-chat .search-box-chat {
    position: relative;
    background: rgba(241, 245, 249, 0.8);
    border-radius: 12px;
    padding: 2px 2px 2px 40px;
    border: 1px solid transparent;
    transition: all 0.3s;
}

.search-box-chat:focus-within {
    background: #fff;
    border-color: var(--chat-primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

.search-box-chat i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--chat-text-muted);
}

.search-box-chat input {
    width: 100%;
    border: none;
    background: transparent;
    padding: 10px 0;
    font-size: 0.9rem;
    outline: none;
    color: var(--chat-text-main);
}

/* Conversations List & Skeleton */
.conversation-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px;
    min-height: 0;
}

.no-conversations {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 300px;
    padding: 20px;
    text-align: center;
}

.no-results-icon {
    width: 60px;
    height: 60px;
    background: #f1f5f9;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    color: #94a3b8;
    font-size: 1.5rem;
}

.no-conversations h6 {
    font-weight: 700;
    color: var(--chat-text-main);
    margin-bottom: 8px;
    font-size: 0.95rem;
}

.no-conversations p {
    font-size: 0.8rem;
    color: var(--chat-text-muted);
    line-height: 1.5;
    max-width: 200px;
}

.skeleton-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    margin-bottom: 2px;
}

.skeleton-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: #f1f5f9;
    position: relative;
    overflow: hidden;
    border: 1px solid #e2e8f0;
}

.skeleton-info {
    flex: 1;
}

.skeleton-name {
    height: 14px;
    width: 50%;
    background: #f1f5f9;
    border-radius: 4px;
    margin-bottom: 8px;
    position: relative;
    overflow: hidden;
}

.skeleton-msg {
    height: 10px;
    width: 80%;
    background: #f1f5f9;
    border-radius: 4px;
    position: relative;
    overflow: hidden;
}

.skeleton-avatar::after,
.skeleton-name::after,
.skeleton-msg::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.8), transparent);
    animation: shimmer 2.5s infinite linear;
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }

    100% {
        transform: translateX(100%);
    }
}

.skeleton-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Chat Loader */
.chat-loader-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    color: var(--chat-text-muted);
}

.chat-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(99, 102, 241, 0.1);
    border-top-color: var(--chat-primary);
    border-radius: 50%;
    animation: chat-spin 0.8s linear infinite;
}

@keyframes chat-spin {
    to {
        transform: rotate(360deg);
    }
}

.conversation-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    margin-bottom: 2px;
}

.conversation-item:hover {
    background: rgba(99, 102, 241, 0.05);
    transform: translateX(4px);
}

.conversation-item.active {
    background: #fff;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.12);
    border-left: 4px solid var(--chat-primary);
    border-top-left-radius: 4px;
    border-bottom-left-radius: 4px;
}

.conversation-item.active .conv-name {
    color: var(--chat-primary);
}

.conv-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--chat-primary-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 600;
    font-size: 1rem;
    flex-shrink: 0;
    overflow: hidden;
    border: 2px solid #fff;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.avatar-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--chat-primary-gradient);
}

.rounded-avatar {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.conv-content {
    flex: 1;
    min-width: 0;
}

.conv-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2px;
}

.conv-name {
    font-weight: 600;
    color: var(--chat-text-main);
    font-size: 0.9rem;
}

.conv-time {
    font-size: 0.7rem;
    color: var(--chat-text-muted);
}

.conv-preview {
    font-size: 0.8rem;
    color: var(--chat-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conv-badge {
    background: var(--chat-primary);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 20px;
    min-width: 20px;
    text-align: center;
}

/* Unassigned Chat Indicator */
.conversation-item.unassigned {
    border-left: 3px solid #f59e0b;
    background: rgba(245, 158, 11, 0.05);
}

.conversation-item.unassigned:hover {
    background: rgba(245, 158, 11, 0.1);
}

.unassigned-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 12px;
    white-space: nowrap;
    flex-shrink: 0;
}

.unassigned-badge i {
    font-size: 0.6rem;
}

.conv-status-group {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    margin-left: auto;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.65rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 12px;
    white-space: nowrap;
    flex-shrink: 0;
}

.status-badge.waiting {
    background: rgba(245, 158, 11, 0.1);
    color: #d97706;
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.status-badge.closed {
    background: #f1f5f9;
    color: #64748b;
    border: 1px solid #e2e8f0;
}

.conversation-item.closed-chat {
    opacity: 0.8;
}

.conversation-item.closed-chat .conv-name {
    color: #94a3b8;
}

.conversation-item.closed-chat .conv-preview {
    color: #94a3b8;
}

.assignment-badge.closed {
    background: #f1f5f9;
    color: #64748b;
    border: 1px solid #e2e8f0;
}

/* Main Chat Area */
.chat-main {
    background: #fff;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}

/* Empty State */
.empty-chat-state {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    background: linear-gradient(45deg, #f8fafc 0%, #f1f5f9 100%);
}

.empty-chat-glass {
    text-align: center;
    padding: 32px 24px;
    background: rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(8px);
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.5);
    max-width: 340px;
}

.empty-chat-icon {
    width: 64px;
    height: 64px;
    background: var(--chat-primary-gradient);
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    color: #fff;
    font-size: 1.8rem;
    box-shadow: 0 15px 20px -5px rgba(99, 102, 241, 0.25);
}

.empty-chat-glass h3 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--chat-text-main);
}

.empty-chat-glass p {
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--chat-text-muted);
    margin-bottom: 0;
}

.empty-chat-glass .start-chat-btn {
    margin-top: 16px;
    padding: 10px 20px;
    font-size: 0.85rem;
}

/* Active Chat */
.active-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #fff;
    height: 100%;
}

.chat-header {
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--chat-border);
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 10;
    flex-shrink: 0;
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    padding: 4px 10px;
    border-radius: 10px;
    transition: all 0.2s;
    user-select: none;
}

.chat-header-info:hover {
    background: rgba(0, 0, 0, 0.03);
}

.chat-header-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--chat-primary-gradient);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    font-weight: 600;
    overflow: hidden;
    border: 2px solid #fff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.chat-header-avatar i {
    font-size: 1.2rem;
}

.header-actions {
    margin-left: auto;
}

.info-btn {
    background: none;
    border: none;
    color: var(--chat-text-muted);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 6px;
    border-radius: 50%;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.info-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--chat-primary);
}

.back-btn {
    display: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid var(--chat-border);
    background: rgba(255, 255, 255, 0.8);
    color: var(--chat-text-muted);
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
    font-size: 0.8rem;
}

.back-btn:hover {
    background: #fff;
    color: var(--chat-primary);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    border-color: var(--chat-primary);
}

.chat-header-details h5 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--chat-text-main);
}

.status-online {
    font-size: 0.8rem;
    color: #10b981;
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
}

.pulse {
    width: 8px;
    height: 8px;
    background: #10b981;
    border-radius: 50%;
    display: inline-block;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    }

    70% {
        transform: scale(1);
        box-shadow: 0 0 0 10px rgba(16, 185, 129, 0);
    }

    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}

.status-dot {
    width: 8px;
    height: 8px;
    background: var(--chat-text-muted);
    border-radius: 50%;
    display: inline-block;
    opacity: 0.5;
}

/* Messages */
/* Main Content Area (Messages + Sidebar) */
.chat-main-content {
    flex: 1;
    display: flex;
    overflow: hidden;
    position: relative;
    min-height: 0;
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: #f8fafc;
    transition: margin-right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    min-height: 0;
}

/* Customer Details Panel */
.customer-details-panel {
    width: 320px;
    background: #fff;
    border: 1px solid var(--chat-border);
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 12px;
    right: -340px;
    /* Hidden state */
    bottom: 12px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 5;
    box-shadow: -10px 10px 30px rgba(0, 0, 0, 0.08);
    border-radius: 16px;
    height: calc(100% - 24px);
}

.customer-details-panel.show {
    right: 12px;
}

.details-header {
    padding: 20px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--chat-border);
}

.details-header h6 {
    margin: 0;
    font-weight: 700;
    color: var(--chat-text-main);
}

#closeDetailsBtn {
    background: none;
    border: none;
    color: var(--chat-text-muted);
    cursor: pointer;
    font-size: 1rem;
    transition: color 0.2s;
}

#closeDetailsBtn:hover {
    color: #ef4444;
}

.details-body {
    padding: 24px 20px;
    overflow-y: auto;
    text-align: center;
}

.avatar-placeholder.big,
.rounded-avatar.big {
    width: 64px;
    height: 64px;
    margin: 0 auto 10px;
    font-size: 1.5rem;
    border: 2px solid #fff;
    box-shadow: 0 8px 12px -3px rgba(0, 0, 0, 0.1);
    border-radius: 50%;
}

#detailsName {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 2px;
    color: var(--chat-text-main);
}

.details-role {
    font-size: 0.75rem;
    color: var(--chat-primary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 20px;
}

.details-info-list {
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.info-item {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.info-item i {
    width: 28px;
    height: 28px;
    background: rgba(99, 102, 241, 0.1);
    color: var(--chat-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-size: 0.8rem;
    flex-shrink: 0;
}

.info-item label {
    display: block;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--chat-text-muted);
    margin-bottom: 1px;
}

.info-item p {
    margin: 0;
    font-size: 0.8rem;
    color: var(--chat-text-main);
    font-weight: 500;
    word-break: break-all;
}

.message {
    display: flex;
    margin-bottom: 4px;
}

.message.sent {
    justify-content: flex-end;
}

.message.received {
    justify-content: flex-start;
}

.message-bubble {
    max-width: 65%;
    padding: 6px 10px;
    border-radius: 12px;
    position: relative;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.message.sent .message-bubble {
    background: var(--chat-primary-gradient);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.message.received .message-bubble {
    background: #fff;
    color: var(--chat-text-main);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--chat-border);
}

/* Message States */
.message.sending {
    opacity: 0.7;
}

.message.failed .message-bubble {
    border: 1px solid #fee2e2;
    background: #fffafa;
}

.message.failed .message-text {
    color: #991b1b;
}

.error-container {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
}

.error-icon {
    color: #ef4444;
    font-size: 0.8rem;
}

.btn-resend {
    background: none;
    border: none;
    color: var(--chat-primary);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
    text-decoration: underline;
}

.btn-resend:hover {
    color: #4338ca;
}

.message-text {
    font-size: 0.85rem;
    line-height: 1.4;
}

.message-meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    margin-top: 4px;
    font-size: 0.7rem;
    opacity: 0.8;
}

.message.received .message-meta {
    color: var(--chat-text-muted);
}

.read-tick {
    font-size: 0.8rem;
}

.read-tick.read {
    color: #fff;
}

/* Date Separator */
.date-separator {
    display: flex;
    justify-content: center;
    margin: 10px 0;
}

.date-separator span {
    background: #fff;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--chat-text-muted);
    border: 1px solid var(--chat-border);
}

/* Floating Input */
.message-input-area {
    padding: 8px 16px 12px;
    background: #f8fafc;
    flex-shrink: 0;
}

.message-input-container {
    background: #fff;
    border-radius: 12px;
    padding: 2px 2px 2px 12px;
    border: 1px solid var(--chat-border);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    transition: all 0.3s;
}

.message-input-container:focus-within {
    border-color: var(--chat-primary);
    transform: translateY(-2px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

.message-form {
    display: flex;
    align-items: center;
    gap: 12px;
}

.message-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 0.9rem;
    color: var(--chat-text-main);
    padding: 6px 0;
}

.send-btn {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    background: var(--chat-primary-gradient);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-size: 0.8rem;
}

.send-btn:hover {
    transform: rotate(10deg) scale(1.1);
    box-shadow: 0 5px 15px rgba(99, 102, 241, 0.4);
}

/* Animations */
.fade-in {
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.scale-up {
    animation: scaleUp 0.2s ease-out;
}

@keyframes scaleUp {
    from {
        transform: scale(0.95);
    }

    to {
        transform: scale(1);
    }
}

/* New Chat Btn Container */
.new-chat-btn-container {
    padding: 20px;
}

.new-chat-btn {
    width: 100%;
    padding: 14px;
    background: var(--chat-primary-gradient);
    color: #fff;
    border: none;
    border-radius: 16px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: 0 10px 15px -3px rgba(99, 102, 241, 0.3);
    transition: all 0.2s;
}

.new-chat-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 20px 25px -5px rgba(99, 102, 241, 0.4);
}

/* Modal */
.chat-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s;
}

.chat-modal {
    background: #fff;
    width: 100%;
    max-width: 450px;
    border-radius: 24px;
    overflow: hidden;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.chat-modal-header {
    padding: 20px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--chat-border);
}

.chat-modal-header h6 {
    margin: 0;
    font-weight: 700;
}

.chat-modal-header button {
    background: none;
    border: none;
    color: var(--chat-text-muted);
    cursor: pointer;
}

.chat-modal-body {
    padding: 24px;
}

#newChatMsg {
    width: 100%;
    height: 120px;
    border: 1px solid var(--chat-border);
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 20px;
    outline: none;
    font-family: inherit;
    resize: none;
}

#newChatMsg:focus {
    border-color: var(--chat-primary);
}

.btn-primary-gradient {
    width: 100%;
    padding: 14px;
    border-radius: 16px;
    background: var(--chat-primary-gradient);
    color: #fff;
    border: none;
    font-weight: 600;
    cursor: pointer;
}

/* Responsive */
@media (max-width: 768px) {
    .support-page {
        padding: 0;
        height: 80vh;
    }

    .chat-container {
        grid-template-columns: 1fr;
        border-radius: 0;
        border: none;
        height: 80vh;
    }

    .chat-sidebar {
        display: flex;
        width: 100%;
        height: 100%;
    }

    .chat-main {
        display: none;
        width: 100%;
        height: 100%;
    }

    /* When a chat is active on mobile */
    .chat-container.mobile-active .chat-sidebar {
        display: none;
    }

    .chat-container.mobile-active .chat-main {
        display: flex;
        position: fixed;
        inset: 0;
        z-index: 100;
        background: #fff;
    }

    .chat-container.mobile-active .back-btn {
        display: flex !important;
    }

    .message-bubble {
        max-width: 85%;
    }
}

/* Disabled State */
.chat-disabled-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    border-radius: 20px;
}

.disabled-content {
    text-align: center;
    padding: 30px;
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.05);
    max-width: 360px;
    border: 1px solid var(--chat-border);
}

.disabled-icon {
    width: 60px;
    height: 60px;
    background: #f1f5f9;
    color: #64748b;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin: 0 auto 15px;
}

.disabled-content h4 {
    margin-bottom: 8px;
    color: var(--chat-text-main);
    font-size: 1.1rem;
    font-weight: 700;
}

.disabled-content p {
    color: var(--chat-text-muted);
    font-size: 0.9rem;
    line-height: 1.5;
    margin: 0;
}

/* Assignment Panel */
.assignment-panel {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border-bottom: 1px solid #f59e0b;
    gap: 12px;
    flex-wrap: wrap;
}

.assignment-status {
    display: flex;
    align-items: center;
}

.assignment-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

.assignment-badge.unassigned {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #f59e0b;
}

.assignment-badge.assigned {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #10b981;
}

.assignment-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.assign-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border: none;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.assign-btn.handle-myself {
    background: linear-gradient(135deg, var(--chat-primary) 0%, var(--chat-accent) 100%);
    color: white;
}

.final-assignee-info {
    display: none;
    align-items: center;
    background: #fff;
    padding: 6px 14px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.final-assignee-info .handled-by {
    font-size: 0.8rem;
    font-weight: 600;
    color: #475569;
    display: flex;
    align-items: center;
    gap: 8px;
}

.final-assignee-info .handled-by i {
    color: #10b981;
}

.assign-btn.handle-myself:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.assign-btn.assign-to {
    background: white;
    color: var(--chat-text-main);
    border: 1px solid var(--chat-border);
}

.assign-btn.assign-to:hover {
    border-color: var(--chat-primary);
    color: var(--chat-primary);
}

.assign-dropdown-container {
    position: relative;
}

.assign-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    min-width: 220px;
    max-height: 250px;
    overflow-y: auto;
    background: white;
    border: 1px solid var(--chat-border);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    z-index: 1000;
    display: none;
}

.assign-dropdown.show {
    display: block;
}

.assign-search {
    position: sticky;
    top: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    background: white;
    border-bottom: 1px solid #e5e7eb;
    z-index: 2;
}

.assign-search i {
    color: var(--chat-text-muted);
    font-size: 0.85rem;
}

.assign-search-input {
    width: 100%;
    border: 1px solid var(--chat-border);
    border-radius: 10px;
    background: #f8fafc;
    padding: 10px 12px;
    font-size: 0.85rem;
    color: var(--chat-text-main);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.assign-search-input:focus {
    outline: none;
    border-color: var(--chat-primary);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.12);
}

.assign-results {
    display: flex;
    flex-direction: column;
}

.dropdown-loading {
    padding: 16px;
    text-align: center;
    color: var(--chat-text-muted);
    font-size: 0.85rem;
}

.assign-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    cursor: pointer;
    transition: background 0.15s;
    border-bottom: 1px solid #f1f5f9;
}

.assign-dropdown-item:last-child {
    border-bottom: none;
}

.assign-dropdown-item:hover {
    background: #f8fafc;
}

.assign-dropdown-item .user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--chat-primary), var(--chat-accent));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.7rem;
    font-weight: 600;
    flex-shrink: 0;
}

.assign-dropdown-item .user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.assign-dropdown-item .user-info {
    flex: 1;
    min-width: 0;
}

.assign-dropdown-item .user-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--chat-text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.assign-dropdown-item .user-role {
    font-size: 0.7rem;
    color: var(--chat-text-muted);
}

/* Avatar Icon Fallback */
.user-avatar .avatar-icon-fallback {
    font-size: 1rem;
    color: #94a3b8;
}

/* Disabled Message Input */
.message-input:disabled {
    background: #f1f5f9;
    cursor: not-allowed;
    opacity: 0.7;
}

.message-input:disabled::placeholder {
    color: #94a3b8;
    font-style: italic;
}

.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Assignment Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.assignment-modal {
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(30px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.assignment-modal.user-selection {
    max-width: 400px;
    max-height: 400px;
}

.assignment-modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
}

.assignment-modal-header h5 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--chat-text-main);
    display: flex;
    align-items: center;
    gap: 10px;
}

.assignment-modal-header h5 i {
    color: var(--chat-primary);
}

.modal-close-btn {
    background: none;
    border: none;
    font-size: 1.2rem;
    color: #94a3b8;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all 0.2s;
}

.modal-close-btn:hover {
    background: #f1f5f9;
    color: var(--chat-text-main);
}

.assignment-modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.customer-info-section {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid #e5e7eb;
}

.customer-avatar-large {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--chat-primary), var(--chat-accent));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 2rem;
    flex-shrink: 0;
}

.customer-avatar-large img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.customer-details {
    flex: 1;
}

.customer-details h6 {
    margin: 0 0 8px 0;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--chat-text-main);
}

.customer-details p {
    margin: 4px 0;
    font-size: 0.85rem;
    color: var(--chat-text-muted);
    display: flex;
    align-items: center;
    gap: 8px;
}

.customer-details p i {
    width: 16px;
    color: var(--chat-primary);
}

.first-message-section label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--chat-text-muted);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.first-message-box {
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 14px;
    font-size: 0.9rem;
    color: var(--chat-text-main);
    line-height: 1.5;
    max-height: 150px;
    overflow-y: auto;
}

.assignment-modal-footer {
    padding: 16px 24px;
    border-top: 1px solid #e5e7eb;
    display: flex;
    gap: 12px;
    background: #f8fafc;
}

.assignment-modal .modal-actions button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex: 1;
}

.assignment-modal .modal-actions button:disabled {
    opacity: 0.6;
    cursor: wait !important;
}

/* User Selection List */
.user-selection-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.user-selection-list .assign-search {
    margin-bottom: 8px;
}

.user-selection-list .assign-results {
    gap: 8px;
}

.user-selection-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
}

.user-selection-item:hover {
    border-color: var(--chat-primary);
    background: #f8fafc;
    transform: translateX(4px);
}

.user-selection-item .user-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--chat-primary), var(--chat-accent));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1rem;
    flex-shrink: 0;
}

.user-selection-item .user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.user-selection-item .user-info {
    flex: 1;
}

.user-selection-item .user-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--chat-text-main);
    margin-bottom: 2px;
}

.user-selection-item .user-role {
    font-size: 0.8rem;
    color: var(--chat-text-muted);
}

/* Loading Spinner for Modals */
.user-selection-list .loading-spinner {
    text-align: center;
    padding: 40px 20px;
    color: var(--chat-text-muted);
    font-size: 0.9rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.user-selection-list .loading-spinner i {
    font-size: 1.5rem;
    color: var(--chat-primary);
}

/* Empty State for User Selection */
.user-selection-list .empty-state {
    text-align: center;
    padding: 30px 20px;
    color: var(--chat-text-muted);
    font-size: 0.9rem;
}

/* Close Ticket Button */
.close-ticket-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    background: #fef2f2;
    color: #ef4444;
    border: 1px solid #fee2e2;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.close-ticket-btn:hover {
    background: #fee2e2;
    transform: translateY(-1px);
}

.close-ticket-btn:active {
    transform: translateY(0);
}

.close-ticket-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.close-ticket-btn i {
    font-size: 0.9rem;
}

@media (max-width: 576px) {
    .close-ticket-btn span {
        display: none;
    }

    .close-ticket-btn {
        padding: 8px;
    }
}

/* Attachments */
.attachment-btn {
    border: none;
    background: none;
    color: var(--chat-text-muted);
    padding: 8px;
    cursor: pointer;
    font-size: 1.1rem;
    transition: all 0.2s;
}

.attachment-btn:hover {
    color: var(--chat-primary);
    background: rgba(99, 102, 241, 0.1);
    border-radius: 50%;
}

.attachment-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.attachment-preview {
    padding: 8px 16px;
    background: #f8fafc;
    border-top: 1px solid var(--chat-border);
}

.message-image {
    max-width: 250px;
    max-height: 200px;
    border-radius: 12px;
    margin-top: 8px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    object-fit: cover;
}

.message-image:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.message-attachment {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(0, 0, 0, 0.05);
    padding: 10px 14px;
    border-radius: 8px;
    margin-top: 8px;
    text-decoration: none;
    color: inherit;
    font-size: 0.9rem;
    border: 1px solid rgba(0, 0, 0, 0.05);
    transition: all 0.2s;
}

.sent .message-attachment {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    border-color: rgba(255, 255, 255, 0.1);
}

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

.sent .message-attachment:hover {
    background: rgba(255, 255, 255, 0.25);
}

.attachment-icon {
    font-size: 1.2rem;
}

.attachment-info {
    display: flex;
    flex-direction: column;
}

.attachment-name {
    font-weight: 500;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.attachment-label {
    font-size: 0.75rem;
    opacity: 0.7;
}

/* Rating Modal */
.rating-group {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-bottom: 24px;
    flex-direction: row-reverse;
}

.rating-star {
    font-size: 2rem;
    color: #cbd5e1;
    cursor: pointer;
    transition: all 0.2s ease;
}

.rating-star:hover,
.rating-star:hover~.rating-star {
    color: #fbbf24;
    transform: scale(1.1);
}

.rating-star.selected {
    color: #fbbf24;
}

/* Fix for hover effect with selection */
.rating-group:hover .rating-star {
    color: #cbd5e1;
}

.rating-group .rating-star:hover,
.rating-group .rating-star:hover~.rating-star {
    color: #fbbf24;
}

.rating-input:checked~.rating-star {
    color: #fbbf24;
}

.rating-textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    font-size: 0.95rem;
    font-family: inherit;
    resize: none;
    height: 100px;
    margin-bottom: 20px;
    transition: border-color 0.2s;
}

.rating-textarea:focus {
    border-color: var(--chat-primary);
    outline: none;
}

.rating-buttons {
    display: flex;
    gap: 12px;
}

.btn-skip {
    flex: 1;
    padding: 12px;
    background: transparent;
    border: 2px solid #e2e8f0;
    color: var(--chat-text-muted);
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-skip:hover {
    background: #f8fafc;
    color: var(--chat-text-main);
}

/* New Chat Button Container */
.new-chat-btn-container {
    padding: 12px 16px;
    background: var(--glass-bg);
    border-top: 1px solid var(--chat-border);
    flex-shrink: 0;
}

.new-chat-btn {
    width: 100%;
    padding: 12px 20px;
    background: var(--chat-primary-gradient);
    color: white;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px -2px rgba(99, 102, 241, 0.3);
}

.new-chat-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px -4px rgba(99, 102, 241, 0.4);
}

.new-chat-btn:active {
    transform: translateY(0);
}

.new-chat-btn i {
    font-size: 1rem;
}

/* Image wrapper for download button */
.message-image-wrapper {
    position: relative;
    display: inline-block;
    margin-top: 8px;
}

.message-image-download {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
    text-decoration: none;
}

.message-image-wrapper:hover .message-image-download {
    opacity: 1;
}

.message-image-download:hover {
    background: rgba(0, 0, 0, 0.8);
}

.attachment-download {
    color: var(--chat-primary);
    padding: 8px;
    font-size: 1rem;
    transition: all 0.2s;
    text-decoration: none;
}

.attachment-download:hover {
    color: #4f46e5;
    transform: scale(1.1);
}

.chat-preview-content {
    display: flex;
    align-items: center;
    gap: 12px;
    background: white;
    padding: 6px 12px;
    border-radius: 8px;
    border: 1px solid var(--chat-border);
    width: fit-content;
    font-size: 0.85rem;
}

.chat-preview-content i {
    color: var(--chat-primary);
}

.chat-preview-content button {
    border: none;
    background: none;
    color: #ef4444;
    cursor: pointer;
    padding: 0 4px;
}