/* Chat Demo Modal — Microsoft Teams chat styling */

.chat-demo-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.chat-demo-overlay.active {
    opacity: 1;
    visibility: visible;
}

.chat-demo-modal {
    width: 100%;
    max-width: 680px;
    max-height: 85vh;
    margin: 1rem;
    background: #f5f5f5;
    border-radius: 8px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    transform: scale(0.95) translateY(10px);
    transition: transform 0.25s ease;
    overflow: hidden;
}

.chat-demo-overlay.active .chat-demo-modal {
    transform: scale(1) translateY(0);
}

/* ===== Teams Title Bar ===== */
.chat-demo-titlebar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    height: 32px;
    background: #5b5fc7;
    flex-shrink: 0;
}

.chat-demo-titlebar-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-demo-titlebar-icon {
    width: 16px;
    height: 16px;
}

.chat-demo-titlebar-text {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 400;
}

.chat-demo-titlebar-controls {
    display: flex;
    align-items: center;
    gap: 0;
}

.chat-demo-titlebar-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: rgba(255, 255, 255, 0.8);
    font-size: 14px;
    cursor: pointer;
    transition: background 0.1s ease;
    line-height: 1;
    padding: 0;
}

.chat-demo-titlebar-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.chat-demo-titlebar-btn-close:hover {
    background: #c42b1c;
    color: #fff;
}

/* ===== Teams Header (channel/chat name) ===== */
.chat-demo-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    border-bottom: 1px solid #e0e0e0;
    background: #fff;
    flex-shrink: 0;
}

.chat-demo-header-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #5b5fc7;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chat-demo-header-avatar img {
    width: 24px;
    height: 24px;
    border-radius: 4px;
}

.chat-demo-header-info {
    flex: 1;
    min-width: 0;
}

.chat-demo-header-name {
    font-size: 14px;
    font-weight: 600;
    color: #242424;
    line-height: 1.3;
}

.chat-demo-header-status {
    font-size: 12px;
    color: #616161;
    line-height: 1.3;
}

/* ===== Chat Body ===== */
.chat-demo-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    background: #f5f5f5;
}

/* ===== Message Rows ===== */
/* Teams-style: avatar + sender name/time on one line, then content below */
.chat-msg {
    display: flex;
    gap: 12px;
    max-width: 95%;
    padding: 6px 0;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.chat-msg.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Agent messages — left aligned */
.chat-msg-agent {
    align-self: flex-start;
}

/* User messages — right aligned, reverse layout */
.chat-msg-user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

/* ===== Avatar ===== */
.chat-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    margin-top: 2px;
}

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

.chat-avatar-user {
    background: #7f85f5;
    color: #fff;
}

/* ===== Bubble ===== */
.chat-bubble {
    border-radius: 4px;
    padding: 8px 12px;
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
    max-width: 100%;
}

.chat-bubble-agent {
    background: #fff;
    color: #242424;
    box-shadow: 0 0.5px 1px rgba(0, 0, 0, 0.1);
}

.chat-bubble-user {
    background: #e8ebfa;
    color: #242424;
    box-shadow: 0 0.5px 1px rgba(0, 0, 0, 0.1);
}

.chat-bubble-header {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 4px;
}

.chat-bubble-sender {
    font-size: 13px;
    font-weight: 600;
    color: #242424;
}

.chat-bubble-time {
    font-size: 12px;
    color: #616161;
    font-weight: 400;
}

.chat-bubble-content {
    color: #242424;
}

/* ===== System action messages ===== */
.chat-msg-system {
    align-self: center;
    max-width: 100%;
    text-align: center;
    padding: 8px 0;
}

.chat-system-text {
    display: inline-block;
    font-size: 12px;
    color: #616161;
    background: #ebebeb;
    border-radius: 4px;
    padding: 6px 14px;
}

/* ===== Typing indicator ===== */
.chat-typing {
    display: flex;
    gap: 12px;
    align-self: flex-start;
    max-width: 90%;
    padding: 6px 0;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.chat-typing.visible {
    opacity: 1;
    transform: translateY(0);
}

.chat-typing-dots {
    background: #fff;
    border-radius: 4px;
    padding: 12px 18px;
    display: flex;
    gap: 5px;
    align-items: center;
    box-shadow: 0 0.5px 1px rgba(0, 0, 0, 0.1);
}

.chat-typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #5b5fc7;
    animation: chatTypingBounce 1.2s infinite ease-in-out;
}

.chat-typing-dot:nth-child(2) {
    animation-delay: 0.15s;
}

.chat-typing-dot:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes chatTypingBounce {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.3;
    }
    30% {
        transform: translateY(-4px);
        opacity: 1;
    }
}

/* ===== Compose Bar (decorative) ===== */
.chat-demo-compose {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: #fff;
    border-top: 1px solid #e0e0e0;
    flex-shrink: 0;
}

.chat-demo-compose-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #d1d1d1;
    border-radius: 4px;
    font-size: 13px;
    color: #ababab;
    background: #f5f5f5;
    cursor: default;
}

.chat-demo-compose-icons {
    display: flex;
    gap: 4px;
}

.chat-demo-compose-icon {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #616161;
    border-radius: 4px;
}

/* ===== Footer (Replay / Learn More) ===== */
.chat-demo-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    border-top: 1px solid #e0e0e0;
    background: #fff;
    flex-shrink: 0;
    gap: 12px;
}

.chat-demo-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 16px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
    border: none;
}

.chat-demo-btn-replay {
    background: #f0f0f0;
    color: #242424;
    border: 1px solid #d1d1d1;
}

.chat-demo-btn-replay:hover {
    background: #e0e0e0;
}

.chat-demo-btn-learn {
    background: #5b5fc7;
    color: #fff;
}

.chat-demo-btn-learn:hover {
    background: #4f52b2;
}

/* ===== Scrollbar ===== */
.chat-demo-body::-webkit-scrollbar {
    width: 6px;
}

.chat-demo-body::-webkit-scrollbar-track {
    background: transparent;
}

.chat-demo-body::-webkit-scrollbar-thumb {
    background: #c7c7c7;
    border-radius: 3px;
}

.chat-demo-body::-webkit-scrollbar-thumb:hover {
    background: #a0a0a0;
}

/* ===== Mobile ===== */
@media (max-width: 640px) {
    .chat-demo-modal {
        max-height: 92vh;
        margin: 0.5rem;
        border-radius: 6px;
    }

    .chat-demo-body {
        padding: 12px 14px;
    }

    .chat-msg {
        max-width: 98%;
    }

    .chat-bubble {
        font-size: 13px;
        padding: 6px 10px;
    }

    .chat-demo-footer {
        flex-direction: column;
        gap: 8px;
    }

    .chat-demo-btn {
        width: 100%;
        justify-content: center;
    }

    .chat-demo-compose {
        display: none;
    }
}
