/* RAG Search specific styles */
:root {
    --primary-bg: #f9f9f7;
    --primary-text: #2C2C2C;
    --primary-border: #e0e0e0;
    --accent-color: #2C2C2C;
    --hover-color: #4a4a4a;
    --user-msg-bg: #e3f2fd;
    --user-msg-color: #2C2C2C;
    --assistant-msg-bg: #f5f5f5;
    --assistant-msg-color: #212121;
    --chip-bg: #f0f0f0;
    --chip-border: #e0e0e0;
    --error-bg: #f8d7da;
    --error-color: #721c24;
    --error-border: #f5c6cb;
    --success-bg: #d4edda;
    --success-color: #155724;
    --success-border: #c3e6cb;
    --muted-text: #6c757d;
}

/* Container layout */
.search-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 0 160px;
    min-height: 100vh;
    position: relative;
    z-index: 1;
    width: 100%;
}

/* Conversation thread */
.conversation-thread {
    padding: 1rem 0; /* Remove horizontal padding to match input width */
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    overflow: visible;
    padding-bottom: 180px;
}

/* Message bubbles */
.message {
    max-width: 80%;
    padding: 0.875rem 1rem;
    line-height: 1.5;
}

.user-message {
    align-self: flex-end;
    color: var(--user-msg-color);
    background-color: var(--user-msg-bg);
}

.assistant-message {
    align-self: flex-start;
    color: var(--assistant-msg-color);
}

/* Message content formatting */
.assistant-message p {
    margin: 0.75rem 0;
}

.assistant-message p:first-child {
    margin-top: 0;
}

.assistant-message p:last-child {
    margin-bottom: 0;
}

.assistant-message ul, 
.assistant-message ol {
    margin: 0.75rem 0 0.75rem 1.5rem;
    padding: 0;
}

.assistant-message h1, 
.assistant-message h2, 
.assistant-message h3 {
    margin: 1.25rem 0 0.75rem;
    line-height: 1.3;
}

/* Code and pre element styling */
.assistant-message pre {
    background-color: #f5f5f5;
    border-radius: 6px;
    padding: 1rem;
    margin: 0.75rem 0;
    overflow-x: auto;
}

.assistant-message code {
    background-color: rgba(0, 0, 0, 0.05);
    border-radius: 3px;
    padding: 0.2em 0.4em;
    font-family: SFMono-Regular, Consolas, Liberation Mono, Menlo, monospace;
    font-size: 0.9em;
}

.assistant-message pre code {
    background-color: transparent;
    padding: 0;
    border-radius: 0;
    white-space: pre;
}

/* Input footer */
.input-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-width: 800px;
    margin: 0 auto;
    border-top: 1px solid var(--primary-border);
    background-color: var(--primary-bg);
    padding: 1rem 35px; /* Match unified container horizontal padding */
    z-index: 100;
    box-sizing: border-box;
}

.search-input {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0.25rem 0;
}

/* Prompt style selector */
.prompt-style-selector {
    display: inline-flex;
}

.prompt-style-selector select {
    appearance: none;
    background-color: var(--primary-bg);
    border: 1px solid var(--primary-border);
    border-radius: 0.5rem;
    color: var(--primary-text);
    font-size: 0.875rem;
    padding: 0.5rem 1.5rem 0.5rem 0.75rem;
    cursor: pointer;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%232c2c2c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    background-size: 12px;
    transition: border-color 0.2s ease;
}

.prompt-style-selector select:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 1px rgba(44, 44, 44, 0.1);
}

.search-input input {
    flex: 1;
    padding: 0.75rem;
    font-size: 1rem;
    border: 1px solid var(--primary-border);
    background-color: var(--primary-bg);
    color: var(--primary-text);
    border-radius: 0.5rem;
    transition: border-color 0.2s ease;
}

.search-input input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 1px rgba(44, 44, 44, 0.1);
}

.search-button {
    padding: 0.75rem;
    background: var(--accent-color);
    color: #fff;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: background-color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.search-button:hover {
    background: var(--hover-color);
}

.new-chat-button {
    font-size: 0.875rem;
    color: var(--muted-text);
    text-decoration: none;
    cursor: pointer;
    display: inline-block;
    margin-top: 0.5rem;
    text-align: center;
    transition: color 0.2s ease;
}

.new-chat-button:hover {
    color: var(--primary-text);
    text-decoration: underline;
}

/* Suggestion chips */
.suggestions-chips {
    padding: 0 1rem 0.5rem;
}

.chips-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

/* In-thread suggestions - minimalist styling */
.chips-container.in-thread {
    display: flex;
    background-color: rgba(249, 249, 247, 0.5);
    border-radius: 0.25rem;
    padding: 0.75rem 1rem;
    margin: 1.5rem auto;
    flex-direction: column;
    width: 100%;
    max-width: 95%;
    border-top: 1px solid #e6e6e6;
    border-bottom: 1px solid #e6e6e6;
    opacity: 1 !important; /* Force visibility */
    z-index: 5; /* Ensure it's above other elements */
}

.chips-container.in-thread .suggestion-chip-wrapper {
    margin-bottom: 0.5rem;
}

.chips-container.in-thread .suggestion-chip {
    color: #2C2C2C;
    font-weight: normal;
    padding: 0.25rem 0;
    transition: all 0.2s ease;
    text-align: left;
    background: none;
    border: none;
    cursor: pointer;
    outline: none;
    width: auto;
    display: inline-block;
    pointer-events: auto !important; /* Force clickability */
}

.chips-container.in-thread .suggestion-chip:hover {
    color: #000;
    text-decoration: underline;
}

.chips-container.in-thread .suggestions-heading {
    margin-bottom: 0.75rem;
    font-weight: 500;
    color: #777;
    font-size: 0.9rem;
    font-style: italic;
    text-align: center;
    padding-bottom: 0.25rem;
}

.suggestions-heading {
    font-size: 0.85rem;
    color: var(--muted-text);
    margin-bottom: 0.5rem;
    font-style: italic;
}

/* Loading states */
.suggestions-loading {
    color: var(--muted-text);
    font-size: 0.8125rem;
    font-style: italic;
    text-align: center;
    margin: 0.75rem 0;
}

/* Follow-up loading indicator - now enabled */
.follow-up-loading {
    display: block;  /* Show follow-up loading indicator */
}

/* Loading indicator */
.loading-indicator {
    display: none;
    text-align: center;
    margin: 0.75rem 0;
    color: var(--primary-text);
    font-style: italic;
    font-size: 0.875rem;
    transition: all 0.3s ease;
    line-height: 1.6;
}

.loading-indicator.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

.loading-indicator.longer-wait {
    font-size: 0.95rem;
    padding: 4px 0;
    letter-spacing: 0.01em;
}

.loading-indicator.extended-wait {
    font-size: 1rem;
    font-weight: 500;
    padding: 6px 0;
    color: var(--accent-color);
    letter-spacing: 0.02em;
}

/* Brain emoji animation for extended wait */
.loading-brain {
    display: inline-block;
    animation: pulseBrain 2s infinite;
    position: relative;
    top: 2px;
    margin-left: 5px;
}

@keyframes pulseBrain {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Status messages */
.status-message {
    margin: 0.5rem 1rem;
    padding: 0.75rem 1rem;
    border-radius: 0.375rem;
    font-size: 0.875rem;
}

.status-message.error {
    background-color: var(--error-bg);
    color: var(--error-color);
    border: 1px solid var(--error-border);
}

.status-message.success {
    background-color: var(--success-bg);
    color: var(--success-color);
    border: 1px solid var(--success-border);
}

/* Streaming animation */
.assistant-message.streaming {
    position: relative;
}

.assistant-message.streaming::after {
    content: '';
    position: absolute;
    bottom: 0.5rem;
    right: 0.5rem;
    width: 6px;
    height: 6px;
    background-color: var(--accent-color);
    border-radius: 50%;
    opacity: 0.5;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { opacity: 0.5; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.2); }
    100% { opacity: 0.5; transform: scale(1); }
}

.ellipsis::after {
    content: '';
    animation: ellipsis 1.5s infinite;
    display: inline-block;
    width: 1em;
    text-align: left;
}

@keyframes ellipsis {
    0% { content: '.'; }
    33% { content: '..'; }
    66% { content: '...'; }
}

/* Responsive adjustments */
@media (max-width: 600px) {
    
    .message {
        max-width: 90%;
        font-size: 15px;
        padding: 0.75rem;
        line-height: 1.4;
    }
    
    .conversation-thread {
        padding: 0.75rem 0; /* Keep horizontal padding removed */
        gap: 1rem;
        padding-bottom: 200px;
    }
    
    .assistant-message pre,
    .assistant-message code {
        max-width: 100%;
        overflow-x: auto;
        white-space: pre-wrap;
        word-break: break-word;
    }
    
    .assistant-message img {
        max-width: 100%;
        height: auto;
    }
    
    .search-input {
        flex-wrap: wrap;
    }
    
    .prompt-style-selector {
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    .prompt-style-selector select {
        width: 100%;
    }
    
    .search-input input {
        font-size: 0.875rem;
        padding: 12px;
        height: 50px;
        border-radius: 8px;
        -webkit-appearance: none;
        appearance: none;
        margin-bottom: 4px;
    }

    .search-button {
        padding: 12px;
        height: 50px;
        min-width: 50px;
        border-radius: 8px;
    }
    
    .suggestion-chip {
        font-size: 0.75rem;
        padding: 0.25rem 0.5rem;
    }
    
    .input-footer {
        padding: 0.75rem 20px; /* Match mobile unified container padding */
    }
    
    .input-footer-inner {
        padding-bottom: env(safe-area-inset-bottom);
    }
    
    .chips-container.in-thread {
        width: 95%;
        max-width: 95%;
    }
}

/* Mobile specific improvements */
@media (max-width: 480px) {
    
    .message {
        max-width: 95%;
    }
    
    .user-message {
        align-self: flex-end;
        border-radius: 16px 16px 4px 16px;
    }
    
    .assistant-message {
        align-self: flex-start;
        border-radius: 16px 16px 16px 4px;
        background-color: var(--assistant-msg-bg);
        padding: 0.75rem;
    }
    
    .assistant-message p,
    .assistant-message li {
        font-size: 15px;
        line-height: 1.4;
    }
    
    .assistant-message h1,
    .assistant-message h2,
    .assistant-message h3 {
        font-size: 1.1rem;
        margin: 0.75rem 0 0.5rem;
    }
    
    .conversation-thread {
        padding: 0.5rem 0; /* Remove horizontal padding to match input width */
        padding-bottom: 200px;
    }
    
    .app-introduction {
        margin: 20px auto;
        padding: 20px;
    }
    
    .app-introduction p {
        font-size: 15px;
        line-height: 1.4;
    }
    
    .input-footer {
        background-color: var(--primary-bg);
        padding: 10px 20px; /* Match mobile unified container padding */
        border-top: 1px solid var(--primary-border);
    }
    
    .search-input {
        margin: 0;
    }
    
    .search-input input {
        font-size: 16px;
        height: 52px;
    }
    
    .search-button {
        height: 52px;
    }
    
    .conversation-thread {
        padding: 0.5rem 0; /* Remove horizontal padding to match input width */
        padding-bottom: 200px;
    }
}

/* Loading message in conversation thread */
.loading-message {
    align-self: center;
    width: 90%;
    max-width: 90%;
    text-align: center;
    background-color: rgba(245, 245, 245, 0.7);
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.85rem;
    color: var(--muted-text);
    font-style: italic;
    margin: 0.5rem 0;
}

.loading-message.longer-wait {
    font-size: 0.95rem;
    padding: 4px 0;
    letter-spacing: 0.01em;
}

.loading-message.extended-wait {
    font-size: 1rem;
    font-weight: 500;
    padding: 6px 0;
    color: var(--accent-color);
    letter-spacing: 0.02em;
}

/* Suggestion chips and wrappers */
.suggestion-chip-wrapper {
    margin-bottom: 0.75rem;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.suggestion-chip {
    color: #444444;
    font-size: 0.9rem;
    cursor: pointer;
    transition: color 0.2s ease;
    padding: 0.25rem 0;
    text-decoration: none;
    background: none;
    border: none;
    text-align: left;
}

.suggestion-chip:hover {
    color: var(--primary-text);
}

.suggestion-topic {
    font-size: 0.75rem;
    color: #777777;
    margin-top: 0.125rem;
    margin-left: 0.125rem;
    font-style: italic;
}

/* News panel styles */
.news-panel-container {
    position: fixed;
    top: 0;
    right: -350px; /* Start offscreen */
    width: 350px;
    height: 100vh;
    background-color: var(--primary-bg);
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
    transition: right 0.3s ease;
    z-index: 200;
    display: flex;
    flex-direction: column;
}

/* This class is no longer needed since we're using inline styles, but keeping for compatibility */
.news-panel-container.open {
    right: 0;
}

.news-panel-header {
    padding: 1rem;
    border-bottom: 1px solid var(--primary-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.news-panel-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--primary-text);
}

.news-panel-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--muted-text);
    font-size: 1.5rem;
    padding: 0.25rem;
    transition: color 0.2s ease;
}

.news-panel-close:hover {
    color: var(--primary-text);
}

.news-panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.news-panel-empty {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--muted-text);
    font-style: italic;
}

.news-article {
    padding: 1rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--primary-border);
}

.news-article:last-child {
    border-bottom: none;
}

.news-article-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.news-article-title a {
    color: var(--primary-text);
    text-decoration: none;
    transition: color 0.2s ease;
}

.news-article-title a:hover {
    color: var(--accent-color);
    text-decoration: underline;
}

.news-article-description {
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    line-height: 1.4;
    color: var(--primary-text);
}

.news-article-meta {
    font-size: 0.8rem;
    color: var(--muted-text);
    display: flex;
    justify-content: space-between;
}

.news-article-source {
    font-weight: 500;
}

.news-article-time {
    font-style: italic;
}

.news-article-term {
    font-size: 0.75rem;
    color: var(--accent-color);
    background-color: rgba(44, 44, 44, 0.05);
    padding: 0.25rem 0.5rem;
    border-radius: 1rem;
    display: inline-block;
    margin-bottom: 0.5rem;
}

/* News toggle button */
.news-toggle {
    position: fixed;
    top: 5rem;
    right: 1rem;
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    background-color: var(--primary-bg);
    color: var(--accent-color);
    border: 1px solid var(--primary-border);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    z-index: 199;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.news-toggle:hover {
    background-color: var(--accent-color);
    color: white;
}

.news-toggle-icon {
    font-size: 1.5rem;
}

.news-toggle-badge {
    position: absolute;
    top: -0.25rem;
    right: -0.25rem;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    background-color: #e53935;
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: pulse 1.5s infinite;
}

/* Flash animation for news icon */
@keyframes flash-attention {
    0% { transform: scale(1); background-color: var(--primary-bg); }
    50% { transform: scale(1.1); background-color: var(--accent-color); color: white; }
    100% { transform: scale(1); background-color: var(--primary-bg); }
}

.news-toggle.flash-attention {
    animation: flash-attention 1s ease;
}

/* Mobile adjustments for news panel */
@media (max-width: 768px) {
    .news-panel-container {
        width: 100%;
        right: -100%; /* Adjust for fullscreen on mobile */
    }
    
    .news-toggle {
        right: 0.5rem;
    }
}

/* Table styling in messages */
.assistant-message table {
    border-collapse: collapse;
    margin: 1rem 0;
    width: 100%;
    overflow-x: auto;
    display: block;
}

.assistant-message th,
.assistant-message td {
    border: 1px solid #e0e0e0;
    padding: 0.5rem;
    text-align: left;
}

.assistant-message th {
    background-color: #f5f5f5;
    font-weight: 500;
}

/* Image styling in messages */
.assistant-message img {
    max-width: 100%;
    height: auto;
    margin: 0.75rem 0;
    border-radius: 4px;
}

/* Blockquote styling */
.assistant-message blockquote {
    border-left: 3px solid #e0e0e0;
    margin: 0.75rem 0;
    padding: 0.5rem 0 0.5rem 1rem;
    color: #555;
    font-style: italic;
} 