/* Modern Chat Widget Styles - Redesigned */
:root {
    --chat-primary: #004aad;
    /* Vibrant Blue from Logo */
    --chat-secondary: #ffde59;
    /* Bright Yellow/Gold from Logo */
    --chat-bg: #000c19;
    --chat-accent: #00A3E0;
}

#tfd-chat-wrapper {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 10000;
    font-family: 'Inter', sans-serif;
}

/* Floating Bubble */
.chat-bubble {
    width: 65px;
    height: 65px;
    background: var(--chat-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 8px 32px rgba(0, 51, 102, 0.4);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 2px solid var(--chat-secondary);
    position: relative;
}

.chat-badge {
    position: absolute;
    top: -45px;
    right: 0;
    /* Aligned to the right of the bubble */
    background: var(--chat-secondary);
    color: #000;
    padding: 6px 12px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 800;
    white-space: nowrap;
    box-shadow: 0 4px 15px rgba(212, 175, 55, 0.4);
    animation: floatBadge 3s infinite ease-in-out;
}

.chat-badge::after {
    content: '';
    position: absolute;
    bottom: -6px;
    right: 25px;
    /* Triangle aligned with bubble center */
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid var(--chat-secondary);
}

@keyframes floatBadge {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-5px);
    }
}

.chat-bubble:hover {
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 12px 40px rgba(0, 51, 102, 0.6);
}

.chat-bubble i {
    color: #fff;
    font-size: 28px;
}

/* Chat Window */
.chat-window {
    position: absolute;
    bottom: 85px;
    right: 0;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 600px;
    max-height: calc(100vh - 120px);
    background: #111827;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(20px) scale(0.95);
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
}

.chat-window.active {
    transform: translateY(0) scale(1);
    opacity: 1;
    visibility: visible;
}

/* Header with Tabs */
.chat-header {
    padding: 24px;
    background: #1f2937;
    color: #fff;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.profile-section {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    border: 2px solid var(--chat-primary);
    object-fit: cover;
}

.profile-info h3 {
    margin: 0;
    font-size: 16px;
}

.profile-info span {
    font-size: 12px;
    color: #9ca3af;
}

/* Tabs Logic */
.chat-tabs {
    background: #111827;
    border-radius: 100px;
    padding: 4px;
    display: flex;
    gap: 4px;
}

.chat-tab {
    flex: 1;
    padding: 10px;
    border-radius: 100px;
    font-size: 13px;
    font-weight: 600;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
    color: #9ca3af;
    background: transparent;
}

.chat-tab.active-ai {
    background: linear-gradient(135deg, var(--chat-primary), var(--chat-secondary));
    color: white;
}

.chat-tab.active-human {
    background: linear-gradient(135deg, var(--chat-secondary), var(--chat-primary));
    color: white;
    box-shadow: 0 4px 12px rgba(212, 175, 55, 0.3);
}

/* Messages Area */
.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background-image: radial-gradient(circle at 2px 2px, rgba(255, 255, 255, 0.02) 1px, transparent 0);
    background-size: 24px 24px;
}

.msg-wrapper {
    display: flex;
    flex-direction: column;
    max-width: 85%;
}

.msg-sender {
    font-size: 11px;
    font-weight: 700;
    margin-bottom: 4px;
    color: #6b7280;
}

.message {
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.user-msg {
    align-self: flex-end;
}

.user-msg .message {
    background: #374151;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.ai-msg,
.admin-msg {
    align-self: flex-start;
}

.ai-msg .message {
    background: rgba(0, 74, 173, 0.05);
    border: 1px solid rgba(0, 74, 173, 0.2);
    color: #fff;
    border-bottom-left-radius: 4px;
}

.admin-msg .message {
    background: rgba(212, 175, 55, 0.1);
    border: 1px solid rgba(212, 175, 55, 0.3);
    color: #fff;
    border-bottom-left-radius: 4px;
}

/* Input Area */
.chat-input-container {
    padding: 20px;
    background: #1f2937;
    display: flex;
    gap: 12px;
}

.chat-input-container input {
    flex: 1;
    background: #111827;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 14px;
    padding: 12px 18px;
    color: #fff;
    outline: none;
    font-size: 16px;
    /* Fix for mobile zoom issue */
}

.btn-send {
    background: var(--chat-primary);
    border: none;
    width: 45px;
    height: 45px;
    border-radius: 14px;
    cursor: pointer;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-send:hover {
    background: #e11d48;
}

.chat-messages::-webkit-scrollbar {
    width: 4px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}