/* ============================================================
   BoardChatPanel — AI chat panel replacing the board inspector
   ============================================================ */

.board-chat-panel {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    outline: none;
}

/* ---- Header ---- */

.chat-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.chat-back-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--r);
    color: var(--ink2);
    cursor: pointer;
    flex-shrink: 0;
    transition: color 120ms ease, border-color 120ms ease;
}

.chat-back-btn:hover {
    color: var(--ink);
    border-color: var(--border2);
}

.chat-board-name {
    flex: 1;
    min-width: 0;
    font-size: 0.75rem;
    color: var(--ink3);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: center;
}

/* ---- Message area ---- */

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-bubble-row {
    display: flex;
}

.chat-bubble-row--ai {
    justify-content: flex-start;
}

.chat-bubble-row--user {
    justify-content: flex-end;
}

.chat-bubble {
    max-width: 88%;
    padding: 9px 12px;
    font-size: 0.85rem;
    line-height: 1.55;
    word-break: break-word;
}

.chat-bubble--ai {
    background: var(--accent-lt);
    color: var(--ink);
    border-radius: var(--r-lg) var(--r-lg) var(--r-lg) var(--r);
}

.chat-bubble--user {
    background: var(--bg3);
    color: var(--ink);
    border-radius: var(--r-lg) var(--r-lg) var(--r) var(--r-lg);
}

/* ---- Review outcome bubble ---- */

.chat-bubble--review-outcome {
    background: transparent;
    color: var(--ink2);
    font-size: 0.8rem;
    font-style: italic;
    line-height: 1.45;
    border-left: 2px solid var(--border2);
    border-radius: 0;
    padding: 6px 10px;
    max-width: 96%;
}

/* ---- Bubble body (markdown content) ---- */

.chat-bubble-body {
    min-width: 0;
}

.chat-bubble-body--markdown p {
    margin: 0 0 0.5em 0;
}

.chat-bubble-body--markdown p:last-child {
    margin-bottom: 0;
}

.chat-bubble-body--markdown ul,
.chat-bubble-body--markdown ol {
    margin: 0.25em 0 0.5em 0;
    padding-left: 1.4em;
}

.chat-bubble-body--markdown li {
    margin-bottom: 0.2em;
}

.chat-bubble-body--markdown strong {
    font-weight: 600;
}

.chat-bubble-body--markdown em {
    font-style: italic;
}

.chat-bubble-body--markdown code {
    font-family: var(--font-editor);
    font-size: 0.8em;
    background: rgba(0, 0, 0, 0.12);
    border-radius: 3px;
    padding: 1px 4px;
}

.chat-bubble-body--markdown h1,
.chat-bubble-body--markdown h2,
.chat-bubble-body--markdown h3 {
    font-size: 0.9rem;
    font-weight: 600;
    margin: 0.5em 0 0.25em 0;
}

.chat-bubble-body--markdown h1:first-child,
.chat-bubble-body--markdown h2:first-child,
.chat-bubble-body--markdown h3:first-child {
    margin-top: 0;
}

/* ---- Thinking bubble ---- */

.chat-bubble--thinking {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 14px;
}

.thinking-dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent);
    animation: thinking-bounce 0.9s ease-in-out infinite;
}

.thinking-dot--1 {
    animation-delay: 0s;
}

.thinking-dot--2 {
    animation-delay: 0.2s;
}

.thinking-dot--3 {
    animation-delay: 0.4s;
}

@keyframes thinking-bounce {
    0%, 100% { transform: scale(0.8); opacity: 0.3; }
    50%       { transform: scale(1.0); opacity: 1.0; }
}

.thinking-label {
    font-size: 0.78rem;
    color: var(--ink3);
    font-style: italic;
}

/* ---- Input area ---- */

.chat-input-area {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.chat-textarea {
    flex: 1;
    min-height: 72px;
    max-height: 240px;
    padding: 8px 10px;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--r);
    color: var(--ink);
    font-size: 0.85rem;
    font-family: inherit;
    line-height: 1.5;
    resize: vertical;
    box-sizing: border-box;
    transition: border-color 150ms ease-in-out;
}

.chat-textarea:focus {
    outline: none;
    border-color: var(--accent);
}

.chat-textarea:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    resize: none;
}

.chat-textarea::placeholder {
    color: var(--ink3);
}

.chat-send-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    background: var(--accent);
    border: none;
    border-radius: var(--r);
    color: #fff;
    cursor: pointer;
    transition: background 120ms ease, opacity 120ms ease;
}

.chat-send-btn:hover:not(:disabled) {
    background: var(--accent-hover);
}

.chat-send-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* ---- Send button spinner ---- */

.send-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: send-spin 0.7s linear infinite;
}

@keyframes send-spin {
    to { transform: rotate(360deg); }
}
