/* Layout scaffolding */
html,
body {
    height: 100%;
}

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main.container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.chat-session-page {
    flex: 1;
    display: flex;
    flex-direction: row-reverse;
    gap: 1.5rem;
    min-height: 0;
}

.chat-session-info {
    flex: 1;
    border-left: 1px solid rgba(0, 0, 0, 0.08);
    padding-left: 1.5rem;
}

.chat-session-chat {
    flex: 3;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    min-height: 0;
}

.chat-session-frame {
    flex: 1;
    display: flex;
    min-height: 0;
}

.chat-session-layout {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-height: 0;
}

.chat-session-scroll-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    gap: 1rem;
    padding-right: 0.5rem;
    min-height: 0;
    max-width: 100%;
    scrollbar-gutter: stable;
}

.chat-session-scroll-area--reversed {
    flex-direction: column-reverse;
}

.chat-session-status-block {
    padding: 0.25rem 0 0.25rem;
}

.chat-message-wrapper {
    background-color: var(--bs-body-bg, #fff);
    max-width: 100%;
    box-sizing: border-box;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* User message bubbles — ensure long content wraps and is fully visible */
.chat-message-content.bg-primary {
    max-width: 85%;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.chat-session-status {
    opacity: 0.85;
}

/* Typing indicator animation */
.typing-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.25rem 0;
}

.typing-indicator span {
    display: inline-block;
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    background-color: #6c757d;
    animation: typing-bounce 1.4s ease-in-out infinite;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing-bounce {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-0.35rem);
        opacity: 1;
    }
}

.chat-input-container {
    position: sticky;
    bottom: 0;
    background-color: var(--bs-body-bg, #fff);
    padding: 0.75rem 0;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.chat-quick-actions {
    display: flex;
    gap: 0.5rem;
}

.chat-input-container .input-group {
    align-items: stretch;
}

.chat-input-container textarea {
    min-height: 3rem;
    max-height: 40vh;
}

.chat-input-container .input-group .btn {
    display: flex;
    align-items: center;
    align-self: stretch;
    height: auto;
}

/* Remove bottom margin from last element in chat message markdown */
.chat-message-content > *:last-child,
.chat-message-content p:last-child,
.chat-message-content pre:last-child,
.chat-message-content ul:last-child,
.chat-message-content ol:last-child,
.chat-message-content blockquote:last-child {
    margin-bottom: 0 !important;
}

/* Disable textarea resizing */
textarea {
    resize: none;
}

/* Table styling for markdown tables in chat messages */
.chat-message-content table {
    border-collapse: separate;
    border-spacing: 0;
    width: 100%;
    margin: 1.25rem 0;
    font-size: 0.8rem;
    line-height: 1.4;
    border: 1px solid #c6cdd5;
    border-radius: 0.5rem;
    overflow: hidden;
    table-layout: fixed;
}

.chat-message-content table th,
.chat-message-content table td {
    padding: 0.5rem 0.6rem;
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid #dee2e6;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.chat-message-content table th {
    background-color: #2c3e50;
    color: #ffffff;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
    border-bottom: 2px solid #1a252f;
}

.chat-message-content table tbody tr {
    transition: background-color 0.15s ease;
}

.chat-message-content table tbody tr:nth-child(odd) {
    background-color: #ffffff;
}

.chat-message-content table tbody tr:nth-child(even) {
    background-color: #f4f6f8;
}

.chat-message-content table tbody tr:hover {
    background-color: #e8edf2;
}

.chat-message-content table tbody tr:last-child td {
    border-bottom: none;
}

/* First column (skill/disposition name) — make it stand out */
.chat-message-content table td:first-child {
    font-weight: 600;
    color: #2c3e50;
    width: 20%;
}

/* Source column styling — last column in framework tables */
.chat-message-content table td:last-child {
    font-size: 0.75rem;
    color: #6c757d;
    width: 12%;
}

/* Rubric table specific — wider cells with more breathing room */
.chat-message-content table td[align] {
    white-space: normal;
}

/* Add left border accent to category headers (h2/h3 before tables) */
.chat-message-content h2,
.chat-message-content h3 {
    margin-top: 2rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.4rem;
    border-bottom: 2px solid #e9ecef;
}

/* Framework section dividers */
.chat-message-content hr {
    margin: 2rem 0;
    border: none;
    border-top: 2px solid #dee2e6;
}

/* Bold source annotations inside table cells */
.chat-message-content table td strong {
    color: #495057;
}

/* Part headers (Part 1, Part 2, etc.) */
.chat-message-content h1 {
    font-size: 1.5rem;
    color: #2c3e50;
    margin-bottom: 0.5rem;
}

.chat-message-content h2 {
    font-size: 1.2rem;
    color: #34495e;
}

.chat-message-content h3 {
    font-size: 1.05rem;
    color: #495057;
}
