/* Section containers and the chat view. */

#viewContainer {
    display: flex;
    flex: 1;
    min-width: 0;
    flex-direction: column;
    overflow: hidden;
    background: var(--glass);
}

#materialsContainer {
    display: flex;
    flex: 1;
    min-width: 0;
    flex-direction: column;
    align-items: center;
    overflow: auto;
    padding: 20px 24px calc(20px + var(--safe-bottom));
    background: var(--color-bg);
}

#chatContainer {
    display: flex;
    flex: 1;
    min-width: 0;
    min-height: 0;
    flex-direction: column;
    align-items: center;
    padding: 24px 32px calc(24px + var(--safe-bottom));
    background: var(--color-bg);
}

.chat {
    display: flex;
    width: 100%;
    max-width: 720px;
    min-height: 0;
    flex: 1;
    flex-direction: column;
    gap: 12px;
}

.chat-messages {
    display: flex;
    min-height: 0;
    flex: 1;
    flex-direction: column;
    gap: 16px;
    overflow-y: auto;
    padding: 8px 4px 16px;
    scrollbar-width: thin;
}

.chat-msg {
    max-width: 85%;
    flex-shrink: 0;
    padding: 12px 16px;
    border-radius: var(--radius-lg);
    line-height: 1.55;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.chat-msg-user {
    align-self: flex-end;
    background: var(--color-accent-strong);
    color: var(--color-on-strong);
}

.chat-msg-assistant {
    align-self: flex-start;
    border: 1px solid var(--color-border);
    background: var(--color-surface-raised);
}

.chat-msg-assistant a {
    color: var(--color-accent);
}

.chat-suggestions {
    display: flex;
    flex-wrap: wrap;
    flex-shrink: 0;
    justify-content: center;
    gap: 8px;
    padding: 2px;
}

.chat-suggestion {
    min-height: var(--touch-target);
    max-width: 100%;
    padding: 8px 14px;
    border: 1px solid var(--color-border-strong);
    border-radius: 999px;
    background: var(--color-surface-raised);
    color: var(--color-text);
    font: inherit;
    font-size: .85rem;
    line-height: 1.4;
    cursor: pointer;
}

.chat-suggestion:hover {
    border-color: var(--color-accent);
    background: var(--color-surface-hover);
}

.chat-status {
    flex-shrink: 0;
    min-height: 1.5em;
    margin: 0;
    color: var(--color-text-muted);
    padding: 0 4px;
    font-size: .8rem;
    line-height: 1.5;
}

.chat-composer {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    flex-shrink: 0;
    gap: 8px 12px;
    align-items: center;
    padding: 12px;
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-lg);
    background: var(--color-surface);
}

.chat-input {
    grid-column: 1 / -1;
    min-width: 0;
    width: 100%;
    box-sizing: border-box;
    min-height: 72px;
    max-height: 160px;
    padding: 10px 12px;
    resize: vertical;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--color-text);
    font: inherit;
    line-height: 1.5;
}

.chat-composer:focus-within {
    border-color: var(--color-accent);
}

.chat-input::placeholder {
    color: var(--color-text-muted);
    opacity: 1;
}

.chat-counter {
    color: var(--color-text-muted);
    font-size: .72rem;
    padding-left: 12px;
    text-align: left;
    font-variant-numeric: tabular-nums;
}

.chat-send {
    border-radius: var(--radius-md);
}

.chat-send:disabled {
    cursor: default;
    opacity: .6;
}

.chat-upsell {
    width: 100%;
    max-width: 520px;
    margin-top: 10vh;
    padding: 22px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    background: var(--color-surface-raised);
    text-align: center;
}

.chat-upsell-text {
    margin: 0 0 12px;
    font-weight: 650;
}

.chat-upsell-btn {
    min-height: var(--touch-target);
    padding: 0 16px;
    border: 1px solid var(--color-accent);
    border-radius: 999px;
    background: transparent;
    color: var(--color-accent);
    font-weight: 650;
    cursor: pointer;
}

.chat-thinking {
    align-self: flex-start;
    padding: 10px 14px;
    border-radius: var(--radius-lg);
    background: var(--color-surface-raised);
    border: 1px dashed var(--color-border);
    color: var(--color-text-muted);
    font-size: .85rem;
    animation: chat-pulse 1.8s ease-in-out infinite;
}

.chat-msg-edited {
    font-size: .75rem;
    font-style: italic;
    color: var(--color-text-muted);
    margin-left: 6px;
}

@keyframes chat-pulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    .chat-thinking {
        animation: none;
        opacity: 0.85;
    }
}

@media (max-width: 720px) {
    #chatContainer {
        padding: 10px 12px calc(10px + var(--safe-bottom));
    }
    .chat-msg {
        max-width: 92%;
        padding: 10px 14px;
    }
    .chat-composer {
        padding: 8px;
    }
}
