/* Chat Container */
.chat-container {
    width: 100%;
    max-width: 800px;
    flex: 1;
    display: none;
    flex-direction: column;
    overflow-y: auto;
    padding: 80px 0 40px 0;
    margin-bottom: 80px;
    scroll-behavior: smooth;
}

.messages {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Message Bubbles */
.message {
    display: flex;
    gap: 16px;
    max-width: 100%;
    animation: fadeIn 0.3s ease;
}

.message.user {
    justify-content: flex-end;
}

.message-content {
    padding: 16px 20px;
    border-radius: 24px;
    font-size: 15px;
    line-height: 1.6;
    max-width: 80%;
}

.message.user .message-content {
    background-color: var(--hover-bg);
    border-bottom-right-radius: 4px;
}

.message.ai .message-content {
    background-color: transparent;
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 4px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.message.ai {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
}

/* Live "what's happening" status line shown above the three-dot loader
   while a turn is in flight — updates as each LangGraph node finishes
   (see script.js's startStatusPolling / renderStatusLine). */
/* Sole loading indicator shown while a turn is in flight — replaces the old
   three-dot bouncing loader entirely (see script.js's showTypingIndicator). */
.agent-status-line {
    font-size: 14px;
    color: var(--text-secondary);
    padding: 8px 4px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.agent-status-line::before {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent-color, #4f8ef7);
    animation: agent-status-pulse 1.2s infinite ease-in-out;
}

@keyframes agent-status-pulse {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 1; }
}

/* "Oh, I got it — you're asking: ..." — only shown when query_manager_node
   actually rewrote the query using chat-history context (see script.js's
   renderNewQueryLabel). Sits above the answer bubble as a quiet aside. */
.new-query-label {
    font-size: 13px;
    font-style: italic;
    color: var(--text-secondary);
    padding: 2px 4px 8px 4px;
    border-bottom: 1px dashed var(--border-color);
    margin-bottom: 4px;
}

.new-query-label strong {
    font-style: normal;
    color: var(--text-primary);
}

.message-actions {
    display: flex;
    gap: 8px;
    padding-left: 4px;
}

.listen-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.listen-btn:hover {
    background-color: var(--hover-bg);
    color: var(--blue-accent);
}

.listen-btn i {
    width: 16px;
    height: 16px;
}

/* Like/Dislike feedback — hidden unless enabled in Settings (see
   script.js's addListenButton) */
.feedback-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.feedback-btn i {
    width: 16px;
    height: 16px;
}

.feedback-btn:hover {
    background-color: var(--hover-bg);
}

.like-btn:hover, .like-btn.active {
    color: #16a34a;
}

.dislike-btn:hover, .dislike-btn.active {
    color: #dc2626;
}

.like-btn.active, .dislike-btn.active {
    background-color: var(--hover-bg);
}

/* Input Area */
.input-container {
    width: 100%;
    max-width: 700px;
    transition: all 0.5s ease;
}

/* State when chat is active */
.content-wrapper.chat-active {
    justify-content: flex-end;
    padding-bottom: 40px;
}

.content-wrapper.chat-active .hero-section {
    display: none;
}

.content-wrapper.chat-active .glow-bg {
    opacity: 0;
}

.content-wrapper.chat-active .chat-container {
    display: flex;
}

.content-wrapper.chat-active .input-container {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
}

.input-box {
    display: flex;
    align-items: center;
    background-color: white;
    border: 1px solid var(--border-color);
    border-radius: 40px;
    padding: 8px 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.05);
    transition: box-shadow 0.2s;
}

.input-box:focus-within {
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.15);
    border-color: #bfdbfe;
}

.add-btn {
    padding: 8px;
}

#userInput {
    flex: 1;
    border: none;
    outline: none;
    padding: 12px 16px;
    font-size: 16px;
    font-family: 'Outfit', sans-serif;
    background: transparent;
    resize: none;
    overflow-y: auto;
    max-height: 200px;
    min-height: 24px;
    line-height: 1.5;
}

#userInput::placeholder {
    color: #9ca3af;
}

#userInput:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.input-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-right: 4px;
}

.pro-badge {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    padding: 4px 10px;
    border-radius: 16px;
    cursor: pointer;
    transition: background 0.2s;
}

.pro-badge:hover {
    background-color: var(--hover-bg);
}

.pro-badge i {
    width: 14px;
    height: 14px;
}

.model-selector {
    position: relative;
}

.model-dropdown {
    position: absolute;
    bottom: 100%;
    left: 0;
    margin-bottom: 8px;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 8px;
    display: none;
    flex-direction: column;
    gap: 4px;
    min-width: 120px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    z-index: 10;
}

.model-dropdown.show {
    display: flex;
}

.model-option {
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-primary);
    transition: background 0.2s;
}

.model-option:hover {
    background: var(--hover-bg);
}

.model-option.active {
    background: var(--hover-bg);
    font-weight: 500;
}

.mic-btn, .send-btn {
    background-color: var(--hover-bg);
    width: 36px;
    height: 36px;
    border-radius: 50%;
}

.mic-btn.recording-active {
    background-color: rgba(239, 68, 68, 0.15) !important;
    border: 1px solid rgba(239, 68, 68, 0.4);
    animation: micPulse 1.5s infinite;
}

@keyframes micPulse {
    0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    70% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.send-btn {
    background-color: var(--text-primary);
    color: white;
}

.send-btn:hover {
    background-color: black;
    color: white;
}

.stop-btn {
    background-color: var(--text-primary);
    color: white;
    position: relative;
}

.stop-btn:hover {
    background-color: black;
}

.stop-btn i {
    width: 14px;
    height: 14px;
}

.stop-btn::before {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 2px solid rgba(59, 130, 246, 0.35);
    border-top-color: #3b82f6;
    animation: stopSpin 0.9s linear infinite;
}

@keyframes stopSpin {
    to { transform: rotate(360deg); }
}

.spin {
    display: inline-block;
    animation: stopSpin 0.9s linear infinite;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Blinking cursor shown at the end of an AI message while it is streaming in */
.stream-cursor {
    display: inline-block;
    width: 2px;
    height: 1em;
    margin-left: 2px;
    vertical-align: text-bottom;
    background-color: var(--text-primary);
    animation: cursorBlink 0.9s step-end infinite;
}

.message-content.streaming {
    min-height: 1.6em;
}

@keyframes cursorBlink {
    0%, 50% { opacity: 1; }
    50.01%, 100% { opacity: 0; }
}

/* Markdown Styles inside AI bubble */
.message.ai .message-content h1, 
.message.ai .message-content h2, 
.message.ai .message-content h3 {
    margin-top: 16px;
    margin-bottom: 8px;
    font-weight: 600;
}

.message.ai .message-content p {
    margin-bottom: 12px;
}

.message.ai .message-content ul {
    margin-left: 20px;
    margin-bottom: 12px;
}

.message.ai .message-content a {
    color: var(--blue-accent);
    text-decoration: none;
}

.message.ai .message-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
}

.message.ai .message-content th, 
.message.ai .message-content td {
    border: 1px solid var(--border-color);
    padding: 8px 12px;
    text-align: left;
}

.message.ai .message-content th {
    background-color: var(--hover-bg);
}