/* === Messages, bubbles, audio player, thinking dots, empty state === */

/* Messages container */
#messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Message layout */
.message {
    display: flex;
    flex-direction: column;
    max-width: 80%;
    min-width: 0;
}

.message.user { align-self: flex-end; }
.message.assistant { align-self: flex-start; }

/* Message bubble */
.message-bubble {
    padding: 8px 16px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    min-width: 0;
    max-width: 100%;
}

.message.user .message-bubble {
    background: var(--user-bg);
    color: var(--user-text);
}

.message.user.telegram .message-bubble {
    background: var(--telegram-bg);
}

.message.assistant .message-bubble {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* Telegram label */
.telegram-label {
    font-size: 11px;
    opacity: 0.75;
    margin-bottom: 4px;
}

/* Timestamp */
.message-time {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 4px;
    opacity: 0.7;
}

.message.user .message-time {
    text-align: right;
}

/* Message content — markdown */
.message-content { word-break: break-word; overflow-wrap: anywhere; overflow-x: auto; }
.message-content p { margin: 0 0 12px 0; }
.message-content p:last-child { margin-bottom: 0; }

.message-content pre {
    background: var(--bg-tertiary);
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 12px 0;
}

.message-content table {
    border-collapse: collapse;
    font-size: 13px;
    display: block;
    overflow-x: auto;
    max-width: 100%;
}

.message-content th, .message-content td {
    padding: 4px 8px;
    border: 1px solid var(--border-color);
    white-space: nowrap;
}

.message-content th {
    background: var(--bg-tertiary);
    font-weight: 600;
}

.message-content code {
    font-family: "SF Mono", Monaco, Consolas, monospace;
    font-size: 13px;
}

.message-content :not(pre) > code {
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 4px;
}

.message-content ul, .message-content ol {
    margin: 8px 0;
    padding-left: 24px;
}

.message-content li { margin: 4px 0; }

/* Audio player */
.audio-player {
    margin-top: 8px;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.audio-button {
    background: none;
    border: none;
    cursor: pointer;
    color: inherit;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 4px;
    transition: background 0.15s;
}

.audio-button:hover {
    background: rgba(0, 0, 0, 0.1);
}

.audio-button svg {
    width: 16px;
    height: 16px;
}

.audio-slider {
    flex: 1;
    height: 4px;
    border-radius: 2px;
    background: rgba(0, 0, 0, 0.2);
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}

.audio-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: inherit;
    cursor: pointer;
}

.audio-slider::-moz-range-thumb {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: inherit;
    cursor: pointer;
    border: none;
}

.audio-time {
    font-size: 11px;
    opacity: 0.7;
    min-width: 40px;
    text-align: right;
}

/* Thinking dots */
.thinking {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 14px;
}

.thinking-dots {
    display: flex;
    gap: 4px;
}

.thinking-dots span {
    width: 8px;
    height: 8px;
    background: var(--text-secondary);
    border-radius: 50%;
    animation: bounce 0.6s infinite;
}

.thinking-dots span:nth-child(2) { animation-delay: 0.15s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}

/* Streaming cursor (kept for compatibility) */
.streaming-cursor {
    display: inline-block;
    width: 8px;
    height: 16px;
    background: var(--accent);
    margin-left: 4px;
    animation: pulse-cursor 0.5s infinite;
}

@keyframes pulse-cursor {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Empty state */
.empty-state {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
}

/* Input area */
#input-area {
    padding: 16px;
    padding-bottom: 16px;
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}

.input-row {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

#message-input {
    flex: 1;
    padding: 8px 16px;
    font-size: 14px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: var(--bg-primary);
    color: var(--text-primary);
    resize: none;
    min-height: 40px;
    max-height: 160px;
    font-family: inherit;
    line-height: 1.5;
}

#message-input:focus {
    outline: none;
    box-shadow: 0 0 0 2px var(--accent);
}

#message-input::placeholder { color: var(--text-secondary); }

#send-btn {
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
}

#send-btn:hover { opacity: 0.9; }
#send-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Mobile */
@media (max-width: 600px) {
    .message { max-width: 95%; }
    #messages { padding: 12px; gap: 12px; }
    .message-bubble { padding: 8px 12px; }
    .message-content ul, .message-content ol { padding-left: 18px; }
    #message-input { font-size: 16px; }
}
