/* --- WIDGET CONTAINER --- */
#model-chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 350px;
    height: 450px;
    background: #1a1a1a;
    border-radius: 15px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: 'Segoe UI', sans-serif;
    z-index: 9999;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* Minimized State */
#model-chat-widget.minimized {
    height: 72px !important;
    border-radius: 15px 15px 0 0;
    transform: translateY(0);
}

/* Hide content when minimized */
#model-chat-widget.minimized .widget-chat-messages,
#model-chat-widget.minimized .chat-input-area {
    display: none;
}

/* Hidden State (Closed) */
.chat-hidden {
    transform: translateY(130%);
    opacity: 0;
    pointer-events: none;
}

/* --- HEADER --- */
.chat-header {
    background: linear-gradient(135deg, #ff00cc, #333399);
    padding: 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: white;
    cursor: pointer;
}

.header-left {
    display: flex;
    align-items: center;
}

.model-avatar {
    position: relative;
    margin-right: 12px;
}

.model-avatar img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid white;
    object-fit: cover;
}

.status-dot {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 10px;
    height: 10px;
    background: #00ff00;
    border-radius: 50%;
    border: 2px solid #333;
}

.chat-controls {
    display: flex;
    gap: 10px;
}

.control-btn {
    background: rgba(0, 0, 0, 0.2);
    border: none;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.control-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.close-btn:hover {
    background: #ff4444;
}

/* --- MESSAGES CONTAINER --- */
.widget-chat-messages {
    flex: 1;
    padding: 20px 15px;
    background-color: #0b141a; 
    background-image: url("https://user-images.githubusercontent.com/15075759/28719144-86dc0f70-73b1-11e7-911d-60d70fcded21.png");
    background-blend-mode: overlay;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Base Bubble Style */
.message {
    max-width: 75%;
    padding: 6px 7px 8px 9px;
    border-radius: 8px;
    font-size: 14.2px;
    line-height: 19px;
    color: #e9edef;
    position: relative;
    word-wrap: break-word;
    box-shadow: 0 1px 0.5px rgba(0,0,0,0.13);
    display: flex;
    flex-direction: column;
}

/* --- MODEL MESSAGES (Received - Left) --- */
.message.received {
    align-self: flex-start;
    background: #202c33;
    border-top-left-radius: 0;
    max-width: 85%; /* Slightly wider for images */
}

/* Tail for received */
.message.received::before {
    content: "";
    position: absolute;
    top: 0;
    left: -8px;
    width: 0;
    height: 0;
    border: 8px solid transparent;
    border-top-color: #202c33;
    border-right-color: #202c33;
}

/* Style for the welcome image inside the bubble */
.welcome-image {
    width: 100%;
    height: auto;
    border-radius: 8px;
    margin-bottom: 8px;
    display: block;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

/* --- USER MESSAGES (Sent - Right) --- */
.message.sent {
    align-self: flex-end;
    background: #005c4b;
    border-top-right-radius: 0;
}

/* Tail for sent */
.message.sent::before {
    content: "";
    position: absolute;
    top: 0;
    right: -8px;
    width: 0;
    height: 0;
    border: 8px solid transparent;
    border-top-color: #005c4b;
    border-left-color: #005c4b;
}

/* --- METADATA (Time & Ticks) --- */
.msg-meta {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 3px;
    margin-top: -4px;
    padding-left: 10px;
    float: right;
    font-size: 11px;
    color: #8696a0;
}

/* The Ticks */
.tick-icon {
    font-size: 14px;
    margin-left: 2px;
    color: #8696a0;
    transition: color 0.3s ease;
}

.tick-icon.read {
    color: #53bdeb;
}

/* --- TYPING INDICATOR --- */
.typing-indicator {
    background: #202c33 !important;
    padding: 12px 15px !important;
    width: fit-content;
    align-self: flex-start;
    border-radius: 15px;
    border-top-left-radius: 0;
    margin-bottom: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    height: 40px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background-color: #33c5ff;
    border-radius: 50%;
    display: inline-block;
    animation: typingWave 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-dot:nth-child(2) {
    animation-delay: -0.16s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0s;
}

/* --- INPUT AREA --- */
.chat-input-area {
    padding: 15px;
    background: #1a1a1a;
    display: flex;
    border-top: 1px solid #333;
}

#chat-input {
    flex: 1;
    background: #333;
    border: none;
    padding: 12px;
    border-radius: 20px;
    color: white;
    outline: none;
}

.chat-input-area button {
    background: none;
    border: none;
    color: #ff00cc;
    font-size: 20px;
    cursor: pointer;
    margin-left: 10px;
    transition: transform 0.2s;
}

.chat-input-area button:hover {
    transform: scale(1.1);
}

/* --- FLOATING TEASER BUTTON --- */
#chat-toggle-container {
    position: fixed;
    bottom: 25px;
    right: 25px;
    z-index: 9998;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

#chat-toggle-btn {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    border: 3px solid #ff00cc;
    padding: 0;
    cursor: pointer;
    position: relative;
    background: #000;
    box-shadow: 0 5px 20px rgba(0,0,0,0.4);
    transition: transform 0.2s;
    overflow: visible;
    display: flex;
    align-items: center;
    justify-content: center;
}

#chat-toggle-btn:hover {
    transform: scale(1.05);
}

.toggle-avatar {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.notification-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: #ff0000;
    color: white;
    font-size: 13px;
    font-weight: bold;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
    z-index: 10;
    animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.teaser-tooltip {
    background: white;
    color: #333;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: bold;
    margin-bottom: 10px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    position: relative;
    right: 10px;
    animation: float 3s ease-in-out infinite;
    pointer-events: none;
    white-space: nowrap;
}

.teaser-tooltip::after {
    content: '';
    position: absolute;
    bottom: -6px;
    right: 25px;
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid white;
}

.pulse-ring {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 3px solid #ff00cc;
    animation: pulse 2s infinite;
    z-index: -1;
}

/* --- ANIMATIONS --- */
@keyframes typingWave {
    0%, 80%, 100% { 
        transform: scale(0.6);
        opacity: 0.6;
    } 
    40% { 
        transform: scale(1.1) translateY(-6px);
        opacity: 1;
        box-shadow: 0 0 10px rgba(51, 197, 255, 0.4);
    }
}

@keyframes pulse {
    0% { transform: scale(1); opacity: 1; }
    100% { transform: scale(1.6); opacity: 0; }
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

@keyframes popIn {
    0% { transform: scale(0); }
    100% { transform: scale(1); }
}

/* --- MOBILE RESPONSIVENESS --- */
@media screen and (max-width: 480px) {
    #model-chat-widget {
        width: 100% !important;
        height: 100% !important;
        bottom: 0 !important;
        right: 0 !important;
        left: 0 !important;
        top: 0 !important;
        border-radius: 0 !important;
        max-width: none;
    }

    .chat-header {
        padding-top: 15px;
        border-radius: 0;
    }

    #model-chat-widget.minimized {
        top: auto !important;
        bottom: 0 !important;
        height: 70px !important;
        border-radius: 0 !important;
    }

    .chat-input-area {
        padding: 15px;
        padding-bottom: calc(15px + env(safe-area-inset-bottom)); 
    }

    #chat-toggle-container {
        bottom: 20px;
        right: 20px;
    }

    #chat-toggle-btn {
        width: 60px;
        height: 60px;
    }

    .teaser-tooltip {
        display: none;
    }

    .message {
        font-size: 16px;
        max-width: 85%;
    }
}