/* ============================================================
   chat.css — Agent shell, hero heading, chat thread and bubbles
   ============================================================ */

/* Agent shell — fills the grid cell in .main */
.agent-shell {
    padding: 0;
    background: transparent;
    border: none;
    box-shadow: none;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
    width: 100%;
}
.agent-shell.chat-active {
    flex: 1;
    overflow-y: auto;
    justify-content: flex-start;
    padding-top: 0.65rem;
    margin-top: 0;
    margin-bottom: 0;
}

/* Hero group — heading + meta text + composer, centered before chat starts */
.hero-group {
    display: flex;
    flex-direction: column;
    gap: 0;
    width: 100%;
}
.agent-shell.chat-active .hero-group { display: contents; }

/* Hero heading */
.agent-header {
    display: flex;
    justify-content: center;
    text-align: center;
    margin-bottom: 0.05rem;
}
.agent-header h2 {
    font-family: 'Inter Display', Inter, system-ui, sans-serif;
    font-size: 3rem;
    line-height: 1.1;
    margin-bottom: 0;
    letter-spacing: -0.03em;
}
.meta {
    text-align: center;
    font-size: 1.3rem;
    margin-bottom: 0.5rem;
    color: #b6c0d1;
}
.agent-header .meta { color: var(--muted); font-size: 0.78rem; }

/* Hide hero elements once chat is active */
.agent-shell.chat-active .agent-header,
.agent-shell.chat-active .meta { display: none; }

/* Chat thread */
.chat-thread {
    display: none;
    width: min(760px, 100%);
    margin: 0 auto;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 0.35rem 0.05rem 0.8rem;
    scrollbar-gutter: stable;
}
.agent-shell.chat-active .chat-thread { display: block; }

/* Chat messages */
.chat-msg { display: flex; margin-bottom: 0.82rem; }
.chat-msg.user      { justify-content: flex-end; }
.chat-msg.assistant { justify-content: flex-start; }

.chat-bubble {
    max-width: min(690px, 92%);
    border-radius: 16px;
    padding: 0.72rem 0.84rem;
    line-height: 1.5;
    font-size: 0.97rem;
    white-space: pre-wrap;
    word-break: break-word;
}
.chat-msg.user .chat-bubble {
    background: var(--chat-user-bg);
    color: var(--chat-user-color);
    border: 1px solid var(--chat-user-border);
    border-bottom-right-radius: 10px;
}
.chat-msg.assistant .chat-bubble {
    background: transparent;
    color: var(--chat-ast-color);
    border: 1px solid var(--chat-ast-border);
    border-bottom-left-radius: 10px;
}

/* Loading shimmer bubble */
.chat-loading {
    position: relative;
    overflow: hidden;
    min-width: 230px;
}
.chat-loading::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(100deg, transparent 0%, rgba(255,255,255,0.08) 45%, transparent 70%);
    transform: translateX(-120%);
    animation: chatShimmer 1.25s ease-in-out infinite;
    pointer-events: none;
}
.chat-loading-lines { display: grid; gap: 0.42rem; margin-bottom: 0.5rem; }
.chat-loading-line  {
    height: 9px;
    border-radius: 999px;
    background: var(--chat-line-bg);
}
.chat-loading-line:nth-child(1) { width: 92%; }
.chat-loading-line:nth-child(2) { width: 84%; }
.chat-loading-line:nth-child(3) { width: 58%; }

.chat-loading-dots { display: inline-flex; gap: 0.3rem; }
.chat-loading-dots span {
    width: 6px; height: 6px;
    border-radius: 999px;
    background: var(--chat-dot-bg);
    animation: loadingDot 1s ease-in-out infinite;
}
.chat-loading-dots span:nth-child(2) { animation-delay: 0.15s; }
.chat-loading-dots span:nth-child(3) { animation-delay: 0.3s; }

/* Source chips in chat bubbles */
.chat-sources {
    display: flex;
    flex-wrap: wrap;
    gap: 0.36rem;
    margin-top: 0.55rem;
}
.chat-source {
    border: 1px solid var(--chat-source-border);
    background: var(--chat-source-bg);
    color: var(--chat-source-color);
    border-radius: 999px;
    font-size: 0.72rem;
    padding: 0.18rem 0.48rem;
}

.chat-inline-actions {
    margin-top: 0.58rem;
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.chat-inline-btn {
    border: 1px solid var(--chat-source-border);
    background: var(--chat-source-bg);
    color: var(--chat-source-color);
    border-radius: 999px;
    font-size: 0.78rem;
    line-height: 1.2;
    padding: 0.24rem 0.58rem;
    cursor: pointer;
    font-family: inherit;
}

.chat-inline-btn:hover {
    color: var(--text);
    border-color: var(--line-strong, #3a4968);
}

/* Typing cursor */
.typing-cursor {
    display: inline-block;
    width: 0.55ch;
    color: var(--typing-cursor-color);
    animation: blinkCursor 1s step-end infinite;
}

/* Agent actions bar */
.agent-actions {
    display: flex;
    gap: 0.45rem;
    flex-wrap: wrap;
    padding: 0.55rem 0 0.35rem;
    width: min(760px, 100%);
    margin-left: auto;
    margin-right: auto;
}
.agent-actions.hidden { display: none; }

/* Escalation panel */
#escalationPanel { margin-top: 0.55rem; }
.agent-shell.escalation-active #escalationPanel { margin-top: auto; }
#escalationPanel .row:last-of-type { justify-content: flex-start; }
.escalation-submit-btn {
    width: 34px;
    height: 34px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: linear-gradient(180deg, var(--escalate-btn-bg-start) 0%, var(--escalate-btn-bg-end) 100%);
    color: var(--escalate-btn-color);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.14s ease, filter 0.14s ease, border-color 0.14s ease;
}
.escalation-submit-btn:hover {
    transform: translateY(-1px);
    filter: brightness(1.05);
    border-color: var(--escalate-btn-hover-border);
}
.escalation-submit-btn:active {
    transform: translateY(0);
    filter: brightness(0.98);
}
.escalation-submit-btn:disabled { opacity: 0.6; cursor: default; }

#detailsInput {
    scrollbar-width: thin;
    scrollbar-color: var(--escalation-scrollbar-thumb) transparent;
}
#detailsInput::-webkit-scrollbar { width: 10px; }
#detailsInput::-webkit-scrollbar-track { background: transparent; }
#detailsInput::-webkit-scrollbar-thumb {
    background: var(--escalation-scrollbar-thumb);
    border-radius: 999px;
    border: 2px solid transparent;
    background-clip: content-box;
}

/* Mini log */
.mini-log { margin-top: 0.5rem; border-top: 1px solid #1f293b; padding-top: 0.45rem; }
.mini-log p  { font-size: 0.76rem; color: var(--muted); margin-bottom: 0.3rem; }
.mini-log ul { list-style: none; display: grid; gap: 0.28rem; }
.mini-log li {
    color: #c9d6f2;
    font-size: 0.78rem;
    border-left: 2px solid #2c3a57;
    padding-left: 0.42rem;
    line-height: 1.35;
}

@media (max-width: 1000px) {
    .agent-header h2 { font-size: 2.3rem; }
    .meta { font-size: 1.05rem; }
}
