:root {
    --th-brand-coral: #FF5A5F; /* The Red/Pink part */
    --th-brand-teal: #2E98A0; /* The Blue/Teal part */
    --th-brand-dark: #2C3E50; /* Dark Text */
    /* Functional Colors */
    --th-primary: var(--th-brand-coral);
    --th-accent: var(--th-brand-teal);
    --th-gradient: linear-gradient(135deg, #5addd1 30%, #FF8A8E 90%);
    --th-white: #ffffff;
    --th-bg-light: #F9FAFB;
    --th-text-main: #333333;
    --th-text-muted: #6B7280;
    --th-border: #E5E7EB;
    --th-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}

#teyaChat {
    position: fixed !important;
    bottom: 15px !important;
    right: 25px !important;
    z-index: 2147483647 !important;
    font-family: 'Poppins', 'Segoe UI', system-ui, sans-serif; /* Modern Font */
    display: block !important;
}

.chat-toggle-btn {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--th-gradient);
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(255, 90, 95, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    position: absolute;
    bottom: 0;
    right: 0;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

    .chat-toggle-btn:hover {
        transform: scale(1.1) rotate(5deg);
        box-shadow: 0 8px 25px rgba(255, 90, 95, 0.5);
    }

    .chat-toggle-btn:active {
        transform: scale(0.95);
    }

/* Smaller, responsive chat sizing */
#chatContainer {
    position: absolute;
    bottom: 76px;
    right: 0;
    width: clamp(280px, 22vw, 340px);
    height: clamp(420px, 58vh, 540px);
    max-width: calc(100vw - 24px);
    max-height: calc(100vh - 110px);
    background: white;
    border-radius: 18px;
    box-shadow: var(--th-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(16px) scale(0.97);
    pointer-events: none;
    visibility: hidden;
    transform-origin: bottom right;
    transition: all 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}

    #chatContainer.active {
        opacity: 1;
        transform: translateY(0) scale(1);
        pointer-events: auto;
        visibility: visible;
    }

.chat-header {
    background: var(--th-gradient);
    padding: 20px;
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

    .chat-header h3 {
        margin: 0;
        font-size: 18px;
        font-weight: 700;
    }

.chat-status {
    font-size: 12px;
    opacity: 0.9;
    margin-top: 2px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: #2ECC71;
    border-radius: 50%;
    box-shadow: 0 0 0 2px rgba(46, 204, 113, 0.3);
}

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

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

.view-section {
    display: none;
    flex-direction: column;
    flex: 1;
    height: 100%;
    overflow: hidden;
}

    .view-section.active-flex {
        display: flex;
    }

.center-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px;
    text-align: center;
    background: white;
}

.brand-icon {
    font-size: 48px;
    color: var(--th-brand-coral);
    background: #FFF5F5; /* Light pink bg */
    width: 90px;
    height: 90px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-8px);
    }
}

.center-content h2 {
    margin: 0 0 10px;
    color: var(--th-text-main);
    font-size: 22px;
    font-weight: 700;
}

.center-content p {
    color: var(--th-text-muted);
    font-size: 15px;
    line-height: 1.6;
    margin-bottom: 30px;
}

.form-group {
    width: 100%;
    margin-bottom: 15px;
    text-align: left;
}

    .form-group label {
        font-size: 13px;
        font-weight: 600;
        color: var(--th-text-main);
        margin-bottom: 6px;
        display: block;
    }

.styled-input {
    width: 100%;
    padding: 14px;
    border: 1px solid var(--th-border);
    border-radius: 12px;
    font-size: 14px;
    outline: none;
    transition: all 0.2s;
    background: #F9FAFB;
}

    .styled-input:focus {
        border-color: var(--th-brand-teal);
        background: white;
        box-shadow: 0 0 0 4px rgba(46, 152, 160, 0.1);
    }

.chat-btn {
    width: 100%;
    padding: 14px;
    border-radius: 12px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    font-size: 15px;
    transition: transform 0.1s;
    letter-spacing: 0.5px;
}

    .chat-btn:active {
        transform: scale(0.98);
    }

    .chat-btn.primary {
        background: var(--th-brand-teal); /* Teal for primary actions (contrast) */
        color: white;
        box-shadow: 0 4px 12px rgba(46, 152, 160, 0.3);
        margin-bottom: 12px;
    }

        .chat-btn.primary:hover {
            background: #258cd1;
        }

    .chat-btn.secondary {
        background: white;
        border: 1px solid var(--th-border);
        color: var(--th-text-muted);
    }

        .chat-btn.secondary:hover {
            background: #F3F4F6;
            color: var(--th-text-main);
        }

#chatMessages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: white;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.system-message {
    font-size: 12px;
    color: var(--th-text-muted);
    text-align: center;
    margin: 10px 0;
    background: #F3F4F6;
    padding: 6px 12px;
    border-radius: 20px;
    align-self: center;
    display: inline-block;
}

.chat-message {
    max-width: 80%;
    display: flex;
    flex-direction: column;
}

.message-bubble {
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
    position: relative;
    word-wrap: break-word;
    box-shadow: 0 2px 5px rgba(0,0,0,0.03);
}

.user-message {
    align-self: flex-end;
    align-items: flex-end;
}

    .user-message .message-bubble {
        background: var(--th-brand-teal);
        color: white;
        border-bottom-right-radius: 4px;
    }

.assistant-message {
    align-self: flex-start;
    align-items: flex-start;
}

    .assistant-message .message-bubble {
        background: #F3F4F6;
        color: var(--th-text-main);
        border-bottom-left-radius: 4px;
    }

.chat-input-area {
    padding: 16px;
    background: white;
    border-top: 1px solid var(--th-border);
    display: flex;
    gap: 10px;
    align-items: center;
}

#chatInput {
    margin: 0;
    border-radius: 24px;
    padding: 12px 20px;
    background: #F3F4F6;
    border: 1px solid transparent;
}

    #chatInput:focus {
        background: white;
        border-color: var(--th-brand-teal);
    }

#sendChatBtn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--th-brand-coral);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    box-shadow: 0 4px 10px rgba(255, 90, 95, 0.3);
}

    #sendChatBtn:hover {
        transform: scale(1.05);
        background: #FF4045;
    }

    #sendChatBtn:disabled {
        background: #E5E7EB;
        box-shadow: none;
        cursor: not-allowed;
    }

.typing-dots {
    display: flex;
    gap: 4px;
    padding: 6px 10px;
}

.dot {
    width: 6px;
    height: 6px;
    background: #9CA3AF;
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out;
}

    .dot:nth-child(1) {
        animation-delay: -0.32s;
    }

    .dot:nth-child(2) {
        animation-delay: -0.16s;
    }

@keyframes bounce {
    0%, 80%, 100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}

.message-sender {
    font-size: 11px;
    color: #6B7280; 
    margin-bottom: 2px;
    margin-left: 12px; 
    font-weight: 500;
    text-transform: capitalize; 
}

.chat-message.assistant-message {
    align-items: flex-start !important; 
}

.chat-message.user-message {
    align-items: flex-end !important;
}

.edited-label {
    font-size: 10px;
    font-style: italic;
    opacity: 0.7;
    margin-left: 4px;
    color: inherit;
}

.chat-message {
    display: flex !important;
    flex-direction: row !important;
    align-items: flex-start !important; /* Start at top */
    gap: 8px; /* Standard gap */
    margin-bottom: 12px;
    width: 100%;
}

.chat-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
    margin-top: 30px;
}

.assistant-message .chat-avatar {
    background: linear-gradient(135deg, #FF5A5F 0%, #FF8A8E 100%);
    order: 0; /* Left */
}

.user-message .chat-avatar {
    background: linear-gradient(135deg, #2E98A0 0%, #258cd1 100%);
    order: 2; /* Right */
    margin-top: 0px;
}

.message-group {
    display: flex;
    flex-direction: column;
    max-width: 75%;
    order: 1; /* Middle */
}

.message-bubble {
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

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

    .assistant-message .message-group {
        align-items: flex-start;
    }

    .assistant-message .message-bubble {
        background: #F3F4F6;
        color: #333;
        border-bottom-left-radius: 2px;
    }

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

    .user-message .message-group {
        align-items: flex-end;
    }

    .user-message .message-bubble {
        background: var(--th-brand-teal);
        color: white;
        border-bottom-right-radius: 2px;
    }

.message-sender {
    font-size: 11px; /* Slightly larger for readability */
    color: #9CA3AF;
    margin-bottom: 4px; /* Space between Name and Bubble */
    margin-left: 0px;
    font-weight: 600;
}

@media (max-width: 480px) {
    #teyaChat {
        right: 12px !important;
        bottom: 12px !important;
    }

    #chatContainer {
        right: 0;
        bottom: 72px;
        width: calc(100vw - 24px);
        height: min(70vh, 520px);
        border-radius: 16px;
    }

    .chat-toggle-btn {
        width: 56px;
        height: 56px;
        font-size: 24px;
    }
}

.view-section {
    display: none;
    flex-direction: column;
    flex: 1;
    height: 100%;
    overflow-y: auto; 
    overflow-x: hidden;
    min-height: 0;
}

    .view-section.active-flex {
        display: flex;
    }

.center-content {
    flex: 1;
    min-height: 0;
    justify-content: flex-start; /* was center */
    padding: clamp(14px, 2vh, 22px);
    overflow-y: auto; /* enables scrolling inside too */
}

.teya-hidden {
    display: none !important;
}

/* One anchor point for BOTH icon + window */
#teyaChat {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 999999;
}

#chatToggle {
    position: absolute;
    right: 0;
    bottom: 0;
}

#chatContainer {
    position: absolute;
    right: 0;
    bottom: 0;
    transform: translateY(12px);
    opacity: 0;
    pointer-events: none;
    transition: transform 200ms ease, opacity 200ms ease;
}

#chatContainer.active {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}

#chatContainer.active ~ #chatToggle,
#chatToggle.teya-hidden {
    display: none !important;
}

