/* Flat, modern chat UI — Light Theme */
:root {
    --bg: #f5f7fb;
    --panel: #ffffff;
    --panel-2: #f7f9ff;
    --text: #111827;
    --muted: #6b7280;
    --primary: #2563eb;
    --accent: #3b82f6;
    --danger: #ef4444;
    --user-bubble: #e8f0ff;
    --assistant-bubble: #f7f8fc;
    --border: rgba(0, 0, 0, 0.08);
    --shadow: 0 8px 28px rgba(0, 0, 0, 0.08);
}

* {
    box-sizing: border-box;
}

html, body {
    height: 100%;
}

body {
    margin: 0;
    font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
    color: var(--text);
    background: var(--bg);
}

.app {
    height: 100%;
    max-width: 960px;
    margin: 0 auto;
    display: grid;
    grid-template-rows: auto 1fr auto;
    gap: 12px;
    padding: 16px;
}

.app__header {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand__logo {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #dbeafe, #e9d5ff);
    border: 1px solid var(--border);
}

.brand__logo img {
    width: 100%;
    height: 100%;
    border-radius: 8px;
    object-fit: cover;
    display: block;
}

.brand__title {
    font-weight: 700;
    letter-spacing: 0.2px;
}

.brand__subtitle {
    font-size: 12px;
    color: var(--muted);
}

.status {
    font-size: 12px;
    color: var(--muted);
}

.status.connect {
    color: forestgreen
}

.chat {
    position: relative;
    overflow: hidden;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow);
}

.messages {
    list-style: none;
    margin: 0;
    padding: 20px 20px 50px 20px;
    height: 100%;
    overflow-y: auto;
    scroll-behavior: smooth;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.message {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

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

.message--user {
    justify-content: flex-end;
    flex-direction: row-reverse;
    align-self: flex-end;
}

.message__avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: #eef2ff;
    flex: 0 0 auto;
    font-size: 14px;
    border: 1px solid var(--border);
}

.message__avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}

.message--user .message__avatar {
    background: #dbeafe;
}

.message__bubble {
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid var(--border);
    max-width: 72ch;
    line-height: 1.4;
    word-wrap: break-word;
    white-space: pre-wrap;
    color: var(--text);
}

.message--user .message__bubble {
    background: var(--user-bubble);
    border-color: rgba(37, 99, 235, 0.25);
}

.message--assistant .message__bubble {
    background: var(--assistant-bubble);
}

.message__meta {
    margin-top: 6px;
    font-size: 11px;
    color: var(--muted);
}

.message--user .message__meta {
    text-align: right;
}

.message--assistant .message__meta {
    text-align: left;
}

.message__bubble img.inline-image {
    display: block;
    max-width: 360px;
    width: 100%;
    height: auto;
    border-radius: 10px;
    margin-top: 8px;
    border: 1px solid var(--border);
}

.typing {
    position: absolute;
    left: 16px;
    bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    opacity: 0;
    pointer-events: none;
    transform: translateY(10px);
    transition: opacity 180ms ease, transform 180ms ease;
    z-index: 2; /* stay above messages */
}

.typing.show {
    opacity: 1;
    transform: translateY(0);
}

.typing__avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    overflow: hidden;
    display: grid;
    place-items: center;
    border: 1px solid rgba(0,0,0,0.08);
    box-shadow: 0 4px 10px rgba(0,0,0,0.12);
}
.typing__avatar img { width:100%; height:100%; object-fit: cover; display:block; border-radius:50%; }

.typing__bubble {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-radius: 999px;
    background: rgba(255,255,255,0.92);
    border: 1px solid rgba(0,0,0,0.08);
    box-shadow: 0 6px 18px rgba(0,0,0,0.10);
    backdrop-filter: blur(6px) saturate(120%);
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    background: linear-gradient(135deg, #6366f1, #3b82f6 60%, #06b6d4);
    opacity: 1;
}

.dot:nth-child(1) {
    animation: dotPulse 0.9s infinite ease-in-out 0s;
}

.dot:nth-child(2) {
    animation: dotPulse 0.9s infinite ease-in-out 0.15s;
}

.dot:nth-child(3) {
    animation: dotPulse 0.9s infinite ease-in-out 0.3s;
}

@keyframes dotPulse {
    0% {
        transform: scale(0.7);
        opacity: 0.4;
    }
    50% {
        transform: scale(1);
        opacity: 1;
    }
    100% {
        transform: scale(0.7);
        opacity: 0.4;
    }
}

.composer {
    display: flex;
    grid-template-columns: auto 1fr auto;
    gap: 10px;
    align-items: center;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 10px;
    box-shadow: var(--shadow);
}

.composer__btn, .composer__send {
    appearance: none;
    border: 1px solid var(--border);
    background: var(--panel-2);
    color: var(--text);
    padding: 10px 12px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    letter-spacing: 0.2px;

}

.composer__btn:hover, .composer__send:hover {
    background: #eef2ff;
}

.composer__input {
    width: 100%;
    background: var(--panel);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 14px;
    outline: none;
}

.composer__input::placeholder {
    color: var(--muted);
}

/* Scrollbar aesthetics */
.messages::-webkit-scrollbar {
    width: 10px;
}

.messages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.12);
    border-radius: 999px;
}

.messages::-webkit-scrollbar-track {
    background: transparent;
}

/* --- Modern enhancements: glass panels, gradient bubbles, icon send button --- */
/* Body bg already set to bg.jpg earlier */

/* Glassy chat panel over background image */
.chat {
    background: rgba(255, 255, 255, 0.45);
    -webkit-backdrop-filter: blur(12px) saturate(140%);
    backdrop-filter: blur(12px) saturate(140%);
    border: 1px solid rgba(255, 255, 255, 0.55);
}

/* Composer glass bar */
.composer {
    background: rgba(255, 255, 255, 0.6);
    -webkit-backdrop-filter: blur(10px) saturate(140%);
    backdrop-filter: blur(10px) saturate(140%);
    border: 1px solid rgba(255, 255, 255, 0.55);
    border-radius: 14px;
    box-shadow: var(--shadow);
}

/* Input focus ring for accessibility */
.composer__input:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

/* Icon-only send button */
.composer__send {
    width: 44px;
    height: 44px;
    border-radius: 999px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #6366f1, #3b82f6 60%, #06b6d4);
    color: #fff;
    border: none;
    box-shadow: 0 10px 20px rgba(99, 102, 241, 0.25);
    transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.2s ease;
}
.composer__send:hover { box-shadow: 0 12px 24px rgba(59, 130, 246, 0.35); transform: translateY(-1px); }
.composer__send:active { transform: translateY(0); box-shadow: 0 8px 16px rgba(59, 130, 246, 0.3); }
.composer__send .icon { width: 20px; height: 20px; display: block; }

/* Screen-reader-only helper */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* Modern bubble aesthetics */
.message--assistant .message__bubble {
    background: rgba(255, 255, 255, 0.82);
    border: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: 0 6px 18px rgba(0,0,0,0.08);
}
.message--user .message__bubble {
    background: linear-gradient(135deg, #6366f1, #3b82f6 60%, #06b6d4);
    color: #fff;
    border: 1px solid rgba(59, 130, 246, 0.25);
    box-shadow: 0 8px 22px rgba(59, 130, 246, 0.25);
}

/* Meta text contrast on gradient bubble */
.message--user .message__meta { color: rgba(255,255,255,0.9); }

/* Typing indicator a bit more visible over background */
.typing .typing__bubble { background: rgba(255, 255, 255, 0.75); border: 1px solid rgba(0,0,0,0.06); }
