/* ===================================================
 * Mindlink AI Interpreter – Flexbox Chat UI
 * =================================================== */

/* ── Container ─────────────────────────────────────── */
.mlai-chat-container {
    display: flex;
    flex-direction: column;
    max-width: 680px;
    margin: 2rem auto;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: #ffffff;
    border: 1px solid #e2e8f0;
}

/* ── Header ────────────────────────────────────────── */
.mlai-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    background: linear-gradient(135deg, #1e3a5f 0%, #2d6a9f 100%);
    color: #ffffff;
    flex-shrink: 0;
}
.mlai-chat-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}
.mlai-chat-header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}
.mlai-chat-logo {
    font-size: 1.5rem;
}
.mlai-chat-title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 600;
    color: #ffffff;
    letter-spacing: 0.3px;
}
.mlai-select {
    padding: 4px 8px;
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.3);
    background: rgba(255,255,255,0.15);
    color: #ffffff;
    font-size: 0.8rem;
    cursor: pointer;
    outline: none;
}
.mlai-select option {
    background: #1e3a5f;
    color: #ffffff;
}
.mlai-btn-icon {
    background: none;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 6px;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.2s;
}
.mlai-btn-icon:hover {
    background: rgba(255,255,255,0.15);
}

/* ── Messages Area ─────────────────────────────────── */
.mlai-chat-messages {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 20px;
    overflow-y: auto;
    background: #f7f9fc;
    scroll-behavior: smooth;
}
.mlai-chat-messages::-webkit-scrollbar {
    width: 6px;
}
.mlai-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}
.mlai-chat-messages::-webkit-scrollbar-thumb {
    background: #c1c9d4;
    border-radius: 3px;
}

/* ── Welcome ───────────────────────────────────────── */
.mlai-welcome-message {
    text-align: center;
    padding: 24px;
    color: #64748b;
    font-size: 0.95rem;
    line-height: 1.6;
}
.mlai-welcome-message p {
    margin: 0;
}

/* ── Message Bubbles ───────────────────────────────── */
.mlai-message {
    display: flex;
    flex-direction: column;
    max-width: 82%;
    animation: mlai-fadeIn 0.25s ease-out;
}
@keyframes mlai-fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.mlai-message--user {
    align-self: flex-end;
}
.mlai-message--assistant {
    align-self: flex-start;
}

.mlai-message-bubble {
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 0.93rem;
    line-height: 1.55;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.mlai-message--user .mlai-message-bubble {
    background: linear-gradient(135deg, #2d6a9f 0%, #1e3a5f 100%);
    color: #ffffff;
    border-bottom-right-radius: 4px;
}

.mlai-message--assistant .mlai-message-bubble {
    background: #ffffff;
    color: #1e293b;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

/* ── Translation Toggle ───────────────────────────── */
.mlai-translation-toggle {
    font-size: 0.75rem;
    color: #94a3b8;
    margin-top: 4px;
    cursor: pointer;
    user-select: none;
    padding: 0 4px;
}
.mlai-translation-toggle:hover {
    color: #2d6a9f;
    text-decoration: underline;
}
.mlai-message--user .mlai-translation-toggle {
    text-align: right;
}
.mlai-translation-text {
    display: none;
    font-size: 0.82rem;
    color: #64748b;
    font-style: italic;
    padding: 6px 16px 0;
}
.mlai-translation-text.mlai-visible {
    display: block;
}

/* ── Language Badge ────────────────────────────────── */
.mlai-lang-badge {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    padding: 1px 6px;
    border-radius: 4px;
    margin-bottom: 4px;
    letter-spacing: 0.5px;
}
.mlai-message--user .mlai-lang-badge {
    background: rgba(255,255,255,0.2);
    color: rgba(255,255,255,0.8);
    align-self: flex-end;
}
.mlai-message--assistant .mlai-lang-badge {
    background: #e8f0fe;
    color: #2d6a9f;
}

/* ── Typing Indicator ─────────────────────────────── */
.mlai-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    max-width: 120px;
}
.mlai-typing-dot {
    width: 8px;
    height: 8px;
    background: #94a3b8;
    border-radius: 50%;
    animation: mlai-bounce 1.4s infinite both;
}
.mlai-typing-dot:nth-child(2) { animation-delay: 0.16s; }
.mlai-typing-dot:nth-child(3) { animation-delay: 0.32s; }
@keyframes mlai-bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40%           { transform: scale(1);   opacity: 1; }
}

/* ── Input Area ────────────────────────────────────── */
.mlai-chat-input-area {
    display: flex;
    flex-direction: column;
    padding: 12px 16px;
    background: #ffffff;
    border-top: 1px solid #e2e8f0;
    flex-shrink: 0;
}
.mlai-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: #f1f5f9;
    border-radius: 12px;
    padding: 8px 12px;
    border: 2px solid transparent;
    transition: border-color 0.2s;
}
.mlai-input-wrapper:focus-within {
    border-color: #2d6a9f;
    background: #ffffff;
}
.mlai-chat-input {
    flex: 1;
    border: none;
    background: transparent;
    resize: none;
    font-size: 0.93rem;
    line-height: 1.5;
    max-height: 120px;
    min-height: 24px;
    outline: none;
    font-family: inherit;
    color: #1e293b;
}
.mlai-chat-input::placeholder {
    color: #94a3b8;
}
.mlai-send-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 10px;
    background: linear-gradient(135deg, #2d6a9f 0%, #1e3a5f 100%);
    color: #ffffff;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform 0.15s, opacity 0.15s;
}
.mlai-send-btn:hover {
    transform: scale(1.05);
}
.mlai-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ── Footer ────────────────────────────────────────── */
.mlai-chat-footer {
    display: flex;
    justify-content: space-between;
    padding: 6px 4px 0;
    font-size: 0.7rem;
    color: #94a3b8;
}
.mlai-char-count {
    font-variant-numeric: tabular-nums;
}

/* ── Security Badge ────────────────────────────────── */
.mlai-security-badge {
    text-align: center;
    padding: 8px;
    font-size: 0.7rem;
    color: #64748b;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
}

/* ── Error Message ─────────────────────────────────── */
.mlai-error {
    text-align: center;
    padding: 8px 16px;
    background: #fef2f2;
    color: #dc2626;
    border-radius: 8px;
    font-size: 0.85rem;
    border: 1px solid #fecaca;
}

/* ── Responsive ────────────────────────────────────── */
@media (max-width: 600px) {
    .mlai-chat-container {
        margin: 0;
        border-radius: 0;
        max-width: 100%;
        height: 100vh;
    }
    .mlai-chat-messages {
        height: calc(100vh - 200px) !important;
    }
    .mlai-message {
        max-width: 90%;
    }
    .mlai-chat-header {
        flex-wrap: wrap;
        gap: 8px;
    }
}
