﻿:root { --user-bubble: #f5f5f5; --assistant-bubble: #f8f0ff; --text-color: #111; --muted: #777; --radius: 12px; }

body { margin: 0; font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background: var(--bg-gradient); color: var(--text-color); display: flex; justify-content: center; align-items: center; height: 100vh; }

/* Layout */
.chat-shell { display: grid; grid-template-rows: auto 1fr auto; width: 100%; max-width: 900px; height: 100%; padding: 10px 24px; box-sizing: border-box; border-radius: 20px; }
.chat-scroll { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; padding: 16px 0; }

/* Bubbles */
.bubble-row { display: flex; flex-direction: column; max-width: 90%; }
    .bubble-row.user { align-self: flex-end; }
    .bubble-row.assistant { align-self: flex-start; }
.bubble { padding: 12px 14px; border-radius: var(--radius); font-size: 15px; line-height: 1.45; }
    .bubble.user { background: var(--user-bubble); }
    .bubble.assistant { background: var(--assistant-bubble); }
    .bubble strong { font-size: 11px; color: var(--muted); text-transform: uppercase; display: block; margin-bottom: 4px; }
    .bubble.assistant .content p { margin: 0.25rem 0; }
    .bubble.assistant .content ul,
    .bubble.assistant .content ol { padding-left: 1.25rem; margin: 0.25rem 0; }
    .bubble.assistant .content a { color: var(--mila-primary, #0078d4); text-decoration: underline; }
    .bubble.assistant .content code { background: #f7f7f7; padding: 2px 4px; border-radius: 3px; }


/* Stamp + actions */
.stamp { font-size: 11px; color: var(--muted); margin-top: 4px; }
.bubble .stamp { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 12px; color: #999; margin-top: 6px; }
.bubble-actions { display: flex; gap: 10px; }
.action-btn { display: flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 500; cursor: pointer; color: #666; transition: color 0.2s ease; user-select: none; background: none; padding: 0; }
    .action-btn:hover { color: #333; }
    .action-btn.active { color: #6c5ce7; }
.action-icon { font-size: 14px; }
.action-label { font-size: 12px; }

/* Toast */
.toast { position: absolute; bottom: 70px; left: 50%; transform: translateX(-50%); background: #333; color: #fff; padding: 8px 16px; border-radius: 8px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity 0.3s ease, transform 0.3s ease; z-index: 2000; }
    .toast.show { opacity: 1; transform: translateX(-50%) translateY(-5px); }

/* Input area */
.chat-compose { border-top: 1px solid rgba(0,0,0,0.05); padding-top: 16px; }
.compose-inner { display: flex; align-items: center; gap: 10px; background: #fff; border-radius: 16px; border: 1px solid #ccc; padding: 8px 12px; }
textarea#userInput { flex: 1; border: none; outline: none; resize: none; font-size: 15px; line-height: 1.35; color: var(--text-color); }
    textarea#userInput::placeholder { color: var(--muted); }

.btn { border: none; background: none; cursor: pointer; padding: 6px; color: var(--accent); font-size: 20px; }
    .btn:hover { opacity: 0.7; }
#stopBtn { display: none; }
.send-btn { background: var(--accent); color: white; width: 42px; height: 42px; border-radius: 12px; border: none; cursor: pointer; transition: background .2s ease; display: flex; align-items: center; justify-content: center; }
    .send-btn:hover { background: var(--accent-2); }
    .send-btn:disabled { opacity: .6; cursor: not-allowed; }

/* Header */
.title-row { display: flex; align-items: center; gap: 10px; }
.chat-logo { width: 45px; border-radius: 8px; }
.chat-header { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 0px 16px 12px 16px; border-bottom: 1px solid rgba(0,0,0,0.05); }
    .chat-header h2 { margin: 0; font-size: 18px; font-weight: 600; letter-spacing: .3px; }
.subtitle { font-size: 13px; color: var(--muted); text-align: center; }
.status-indicator { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; color: #666; margin-top: -7px; }
    .status-indicator .dot { width: 10px; height: 10px; border-radius: 50%; background: gray; animation: pulse 1.5s infinite; }
    .status-indicator.connected .dot { background: #3BC3C9; }
    .status-indicator.connecting .dot { background: orange; }
    .status-indicator.disconnected .dot { background: red; }
    .status-indicator.connected .label { color: #3BC3C9; }
    .status-indicator.connecting .label { color: orange; }
    .status-indicator.disconnected .label { color: red; }

/* Chat actions (header buttons) */
.chat-actions { display: flex; gap: 8px; margin-left: auto; position: absolute; top: 14px; right: 22px; }
.chat-btn { background: transparent; border: none; color: #555; cursor: pointer; padding: 6px; border-radius: 6px; transition: background 0.2s ease, color 0.2s ease; display: flex; align-items: center; justify-content: center; }
    .chat-btn:hover { background: rgba(0, 0, 0, 0.05); color: var(--accent); }

/* Scrollbars */
.chat-scroll::-webkit-scrollbar { width: 8px; }
.chat-scroll::-webkit-scrollbar-thumb { background: linear-gradient(var(--accent), var(--accent-2)); border-radius: 4px; }
.chat-scroll::-webkit-scrollbar-track { background: transparent; }
.chat-scroll { scrollbar-width: thin; scrollbar-color: var(--accent) transparent; }

/* Cursor animation */
.cursor { display: inline-flex; align-items: center; gap: 4px; margin-left: 6px; width: 28px; height: 10px; }
    .cursor::before, .cursor::after, .cursor span { content: ''; display: block; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: blinkDot 1.4s infinite both; }
    .cursor span { animation-delay: 0.2s; }
    .cursor::after { animation-delay: 0.4s; }

.chat-audio { width: 100%; /* or a fixed width like 320px max-width: 420px; */ }

@keyframes blinkDot {
    0%, 80%, 100% { opacity: 0.2; transform: scale(0.8); }
    40% { opacity: 1; transform: scale(1.2); }
}

/* 📱 Mobile layout fixes */
@media (max-width: 767px) {

    /* Move top-right buttons below the title */
    .chat-actions {
        position: static;
        margin-left: 0;
        justify-content: center;
        margin-top: 6px;
        gap: 12px;
    }

    /* Adjust header to stack title + actions vertically */
    .chat-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 6px;
    }

    .chat-header h2 {
        font-size: 16px;
        text-align: center;
    }

    /* 📱 Mobile input layout refinement */
    @media (max-width: 767px) {

        /* Top-right buttons fix (keep from your version) */
        .chat-actions { position: static; margin-left: 0; justify-content: center; margin-top: 6px; gap: 12px; }

        .chat-header { flex-direction: column; align-items: center; text-align: center; gap: 6px; }

            .chat-header h2 { font-size: 16px; text-align: center; }

        /* ✅ Input area: send button next to textarea only */
        .compose-inner { display: flex; flex-direction: row; align-items: center; gap: 8px; background: #fff; border: 1px solid #ccc; border-radius: 16px; padding: 6px 10px; }

        textarea#userInput { flex: 1 1 auto; min-height: 60px; font-size: 15px; line-height: 1.4; padding: 6px 8px; border: none; outline: none; resize: none; color: var(--text-color); background: transparent; }

        .send-btn { flex-shrink: 0; width: 42px; height: 42px; border-radius: 12px; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; }

        /* Let .compose-inner wrap its children */
        .compose-inner { flex-wrap: wrap; align-items: center; }

        /* ✅ Force .chat-input-bar to start on a new line */
        .chat-input-bar { flex-basis: 100%; width: 100%; display: block; justify-content: space-between; align-items: center; gap: 10px; margin-top: 6px; text-align: center; }
    }


}
