/* =============================================
   AI Chat & Message Styles
   Extracted from style.css + merged from chat.css
   ============================================= */

/* ---- AI Section (Embedded in page) ---- */

.ai-section {
    margin-top: var(--spacing-xl);
    background: rgba(13, 27, 42, 0.6);
    border: 1px solid rgba(255, 215, 0, 0.3);
    border-radius: 0.5rem;
    padding: var(--spacing-xl);
    display: none;
    animation: fadeInUp 0.6s ease;
}

.ai-section.show {
    display: block;
}

.ai-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: var(--spacing-lg);
    margin-bottom: var(--spacing-xl);
}

.ai-title {
    font-family: 'Ma Shan Zheng', cursive;
    font-size: 1.8em;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.ai-container {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xl);
    height: 37.5rem;
}

.ai-chat-window {
    flex-grow: 1;
    border: 1px solid rgba(255, 215, 0, 0.1);
    border-radius: 0.5rem;
    background: rgba(0, 0, 0, 0.3);
    padding: var(--spacing-xl);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xl);
}

.ai-controls-area {
    background: rgba(255, 255, 255, 0.05);
    padding: var(--spacing-xl);
    border-radius: 0.5rem;
    border: 1px solid rgba(255, 215, 0, 0.1);
}

/* ---- Quick Actions ---- */

.quick-actions {
    display: flex;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-lg);
    flex-wrap: wrap;
}

.action-btn {
    background: rgba(27, 38, 59, 0.8);
    border: 1px solid var(--accent-color);
    color: var(--text-color);
    padding: var(--spacing-sm) var(--spacing-lg);
    border-radius: 1.25rem;
    cursor: pointer;
    transition: all 0.2s;
    font-size: var(--font-sm);
}

.action-btn:hover {
    background: var(--primary-color);
    color: #0d1b2a;
    border-color: var(--primary-color);
}

/* ---- AI Input Group ---- */

.ai-input-group {
    display: flex;
    gap: 0.75rem;
    align-items: stretch;
    transition: all 0.3s ease;
}

.ai-input-group.debate-mode {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
}

.ai-input-group.debate-mode .debate-bottom-config {
    width: 100%;
    flex-basis: 100%;
}

.ai-input-group.debate-mode .ai-input {
    min-height: 5rem;
    font-size: var(--font-base);
    flex: 1;
}

.ai-input-group.debate-mode .ai-debate-btn {
    font-size: var(--font-lg);
    padding: 0.75rem var(--spacing-lg);
    white-space: nowrap;
    min-width: 6.25rem;
}

/* ---- Debate Config Panel ---- */

.debate-bottom-config {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 215, 0, 0.25);
    border-radius: 0.625rem;
    overflow: hidden;
}

.debate-bottom-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-sm) var(--spacing-md);
    background: rgba(255, 215, 0, 0.08);
    font-size: var(--font-sm);
    color: #ffd700;
    font-weight: 500;
}

.debate-cancel-btn {
    background: none;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #aaa;
    padding: var(--spacing-xs) 0.75rem;
    border-radius: 0.375rem;
    cursor: pointer;
    font-size: var(--font-xs);
    transition: all 0.2s;
}

.debate-cancel-btn:hover {
    border-color: #ff5252;
    color: #ff5252;
}

.debate-bottom-body {
    padding: 0.75rem var(--spacing-md);
}

.debate-config-row {
    display: flex;
    gap: var(--spacing-xl);
    margin-bottom: var(--spacing-sm);
}

.debate-config-section {
    flex: 1;
}

.debate-bottom-input-row {
    display: flex;
    gap: var(--spacing-sm);
    margin-top: var(--spacing-sm);
}

.debate-bottom-input-row .ai-input {
    height: 3.125rem;
}

.debate-go-btn {
    white-space: nowrap;
    padding: 0 var(--spacing-xl);
    font-size: var(--font-base);
    min-width: 5.625rem;
}

/* ---- AI Input & Send ---- */

.ai-input {
    flex-grow: 1;
    padding: var(--spacing-lg);
    border: 1px solid rgba(255, 215, 0, 0.2);
    background: rgba(0, 0, 0, 0.3);
    color: #fff;
    border-radius: 0.5rem;
    resize: none;
    height: 3.75rem;
    font-family: inherit;
    font-size: var(--font-base);
    transition: border-color 0.3s;
}

.ai-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.ai-send-btn {
    width: 6.25rem;
    background: var(--primary-color);
    color: #0d1b2a;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    font-family: 'Ma Shan Zheng', cursive;
    font-size: var(--font-xl);
    transition: background 0.3s;
}

.ai-send-btn:hover {
    background: #e6c200;
}

.ai-send-btn:disabled {
    background: #555;
    cursor: not-allowed;
}

/* ---- Debate Button ---- */

.ai-debate-btn {
    width: 6.25rem;
    background: linear-gradient(135deg, #8b0000, #c41e3a);
    color: #ffd700;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    font-family: 'Ma Shan Zheng', cursive;
    font-size: var(--font-lg);
    transition: background 0.3s, opacity 0.3s;
    position: relative;
    animation: debatePulse 2.5s ease-in-out infinite;
}

@keyframes debatePulse {
    0%, 100% { box-shadow: 0 0 4px rgba(255, 215, 0, 0.2); }
    50% { box-shadow: 0 0 14px rgba(255, 215, 0, 0.5), 0 0 4px rgba(196, 30, 58, 0.6); }
}

.ai-debate-btn::after {
    content: '真理越辩越明，更准确 ✨';
    position: absolute;
    bottom: calc(100% + 0.5rem);
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.85);
    color: #ffd700;
    padding: 0.375rem 0.75rem;
    border-radius: 0.375rem;
    font-size: var(--font-xs);
    font-family: -apple-system, 'Microsoft YaHei', sans-serif;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
    border: 1px solid rgba(255, 215, 0, 0.3);
}

.ai-debate-btn:hover::after {
    opacity: 1;
}

.ai-debate-btn:hover {
    background: linear-gradient(135deg, #a00000, #d42e4a);
    animation: none;
    box-shadow: 0 0 16px rgba(255, 215, 0, 0.6);
}

.ai-debate-btn:disabled {
    background: #555;
    color: #999;
    cursor: not-allowed;
    animation: none;
    box-shadow: none;
}

.ai-debate-btn:disabled::after {
    display: none;
}

/* ---- Message Styles (Embedded AI section) ---- */

.message {
    max-width: 80%;
    padding: var(--spacing-lg) var(--spacing-xl);
    border-radius: 0.75rem;
    line-height: 1.6;
    position: relative;
    word-wrap: break-word;
}

.message.user {
    align-self: flex-end;
    background: rgba(29, 53, 87, 0.8);
    border-bottom-right-radius: 2px;
    border: 1px solid rgba(119, 141, 169, 0.3);
    color: #e0e1dd;
}

.message.ai {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.05);
    border-bottom-left-radius: 2px;
    border: 1px solid rgba(255, 215, 0, 0.2);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    color: #e0e1dd;
}

.sender-name {
    font-size: 0.8em;
    color: var(--accent-color);
    margin-bottom: var(--spacing-xs);
    display: block;
}

.message .sender {
    font-size: var(--font-xs);
    color: var(--accent-color);
    margin-bottom: var(--spacing-xs);
    display: block;
}

/* ---- Start Button Overlay ---- */

.start-ai-overlay {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    color: var(--accent-color);
}

.privacy-notice {
    margin: var(--spacing-lg) var(--spacing-xl);
    padding: 0.75rem var(--spacing-lg);
    background: rgba(255, 215, 0, 0.06);
    border: 1px solid rgba(255, 215, 0, 0.15);
    border-radius: 0.625rem;
    font-size: var(--font-xs);
    color: #bbb;
    line-height: 1.6;
    max-width: 25rem;
}

.btn-start-ai {
    margin-top: var(--spacing-xl);
    background: linear-gradient(135deg, #b8860b, #ffd700);
    color: #0d1b2a;
    padding: var(--spacing-lg) var(--spacing-2xl);
    font-size: var(--font-xl);
    border: none;
    border-radius: 3.125rem;
    cursor: pointer;
    box-shadow: 0 5px 15px rgba(184, 134, 11, 0.4);
    transition: transform 0.2s;
    font-family: inherit;
    font-weight: bold;
}

.btn-start-ai:hover {
    transform: scale(1.05);
}

.start-buttons {
    display: flex;
    gap: var(--spacing-xl);
    margin-top: var(--spacing-xl);
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
}

.start-buttons .btn-start-ai {
    margin-top: 0;
}

.btn-start-debate {
    background: linear-gradient(135deg, #8b0000, #c41e3a);
    color: #ffd700;
    padding: var(--spacing-lg) 2.1875rem;
    font-size: var(--font-xl);
    border: none;
    border-radius: 3.125rem;
    cursor: pointer;
    box-shadow: 0 5px 15px rgba(139, 0, 0, 0.4);
    transition: transform 0.2s;
    font-family: inherit;
    font-weight: bold;
}

.btn-start-debate:hover {
    transform: scale(1.05);
}

/* ---- Thinking Process ---- */

.thinking-process {
    font-size: var(--font-sm);
    color: #ccc;
    background: rgba(0, 0, 0, 0.2);
    border-left: 3px solid var(--accent-color);
    padding: var(--spacing-sm) 0.75rem;
    margin-bottom: var(--spacing-sm);
    border-radius: 0 4px 4px 0;
    display: none;
}

.thinking-process.active {
    display: block;
    margin-top: var(--spacing-xs);
}

.thinking-header {
    font-size: 0.8em;
    font-weight: bold;
    color: var(--accent-color);
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

.thinking-header::before {
    content: '▶';
    font-size: 0.8em;
    transition: transform 0.2s;
}

.thinking-process.expanded .thinking-header::before {
    transform: rotate(90deg);
}

.thinking-content {
    margin-top: var(--spacing-xs);
    white-space: pre-wrap;
    display: none;
    max-height: 12.5rem;
    overflow-y: auto;
    font-size: var(--font-xs);
    color: #aaa;
    line-height: 1.5;
}

.thinking-process.expanded .thinking-content {
    display: block;
}

/* ---- Chat Widget (Floating) ---- */

.chat-widget {
    position: fixed;
    bottom: var(--spacing-xl);
    right: var(--spacing-xl);
    z-index: 1000;
    font-family: 'Noto Serif SC', serif;
}

.chat-toggle-btn {
    width: 3.75rem;
    height: 3.75rem;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), #b8860b);
    color: #0d1b2a;
    border: none;
    box-shadow: 0 4px 15px rgba(184, 134, 11, 0.4);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.875rem;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.chat-toggle-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(184, 134, 11, 0.6);
}

.chat-container {
    position: absolute;
    bottom: 5rem;
    right: 0;
    width: 23.75rem;
    height: 37.5rem;
    background: rgba(13, 27, 42, 0.95);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease;
    backdrop-filter: blur(10px);
}

.chat-container.open {
    display: flex;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(1.25rem);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-header {
    padding: var(--spacing-lg);
    background: rgba(27, 38, 59, 0.9);
    color: #ffd700;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--secondary-color);
}

.chat-title {
    font-family: 'Ma Shan Zheng', cursive;
    font-size: var(--font-xl);
    letter-spacing: 1px;
}

.chat-controls {
    display: flex;
    gap: var(--spacing-sm);
    align-items: center;
}

.model-select {
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: 4px;
    border: 1px solid var(--accent-color);
    background: rgba(13, 27, 42, 0.8);
    font-size: var(--font-xs);
    color: #e0e1dd;
    cursor: pointer;
}

.close-chat {
    background: none;
    border: none;
    color: var(--accent-color);
    cursor: pointer;
    font-size: var(--font-xl);
    padding: 0 var(--spacing-xs);
}

.close-chat:hover {
    color: #fff;
}

.chat-messages {
    flex-grow: 1;
    padding: var(--spacing-lg);
    overflow-y: auto;
    background-color: transparent;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
}

/* ---- Chat Input Area (Floating widget) ---- */

.chat-input-area {
    padding: var(--spacing-lg);
    background: rgba(13, 27, 42, 0.95);
    border-top: 1px solid rgba(255, 215, 0, 0.1);
    display: flex;
    gap: var(--spacing-sm);
}

.chat-input {
    flex-grow: 1;
    padding: var(--spacing-sm);
    border: 1px solid var(--accent-color);
    border-radius: 0.375rem;
    resize: none;
    height: 2.5rem;
    font-family: inherit;
    background: rgba(0, 0, 0, 0.3);
    color: #fff;
    transition: all 0.3s;
}

.chat-input:focus {
    outline: none;
    border-color: var(--primary-color);
    height: 3.75rem;
}

.send-btn {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    background: var(--primary-color);
    color: #0d1b2a;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    align-self: flex-end;
}

.send-btn:hover {
    background: #e6c200;
    transform: translateY(-2px);
}

.send-btn:disabled {
    background: #555;
    cursor: not-allowed;
    transform: none;
}

/* ---- Scrollbar for chat ---- */

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #555;
    border-radius: 3px;
}

/* ---- AI Typing Indicator ---- */

.ai-typing-indicator {
    color: #888;
    font-size: var(--font-sm);
    animation: typingPulse 1.5s ease-in-out infinite;
}

.typing-dots {
    animation: typingDots 1.2s steps(4, end) infinite;
}

@keyframes typingPulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

@keyframes typingDots {
    0% { content: ''; }
    25% { content: '.'; }
    50% { content: '..'; }
    75% { content: '...'; }
}

/* ---- Multi-Model Tags & Answers ---- */

.multi-model-tag {
    background: rgba(255, 215, 0, 0.1);
    color: #ffd700;
    font-size: 0.78em;
    font-weight: bold;
    padding: 3px var(--spacing-sm);
    border-radius: 4px;
    margin-bottom: 0.375rem;
    display: inline-block;
}

.followup-model-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    padding: var(--spacing-xs) 0;
}

.fp-model {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--spacing-md);
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.04);
    cursor: pointer;
    transition: all 0.2s;
    font-size: var(--font-xs);
    color: #888;
    user-select: none;
}

.fp-model.selected {
    border-color: rgba(255, 215, 0, 0.4);
    background: rgba(255, 215, 0, 0.08);
    color: #ffd700;
}

.fp-model:hover {
    border-color: rgba(255, 215, 0, 0.3);
}

.fp-model-name {
    white-space: nowrap;
}

.fp-model-cost {
    font-size: 0.9em;
    opacity: 0.7;
}

.followup-cost {
    font-size: var(--font-xs);
    color: #ffd700;
    white-space: nowrap;
    align-self: center;
}

.multi-model-hint {
    color: #999;
    font-size: 0.82em;
    text-align: center;
    padding: var(--spacing-sm);
    margin: var(--spacing-sm) 0;
}

.multi-model-answer {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 0.75rem;
    margin: var(--spacing-sm) 0;
    overflow: hidden;
}

.multi-model-header {
    background: rgba(255, 215, 0, 0.08);
    color: #ffd700;
    font-size: var(--font-xs);
    font-weight: bold;
    padding: var(--spacing-sm) 0.875rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.multi-model-content {
    padding: 0.75rem 0.875rem;
    color: #ddd;
    font-size: var(--font-sm);
    line-height: 1.7;
}

.multi-model-content .typing-indicator {
    display: flex;
    gap: var(--spacing-xs);
    padding: var(--spacing-xs) 0;
}

.multi-model-content .typing-indicator span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #ffd700;
    animation: typingBounce 1.4s infinite;
}

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

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

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* ---- Chat Tip Bubble ---- */

.chat-tip-bubble {
    background: rgba(255, 215, 0, 0.08);
    border-left: 3px solid rgba(255, 215, 0, 0.4);
    color: #999;
    font-size: 0.8em;
    padding: var(--spacing-sm) 0.75rem;
    margin: var(--spacing-sm) 0;
    border-radius: 0 0.5rem 0.5rem 0;
    animation: tipFadeIn 0.5s ease;
    transition: opacity 0.5s ease;
}

@keyframes tipFadeIn {
    from { opacity: 0; transform: translateY(0.625rem); }
    to { opacity: 1; transform: translateY(0); }
}

/* ---- AI Welcome Tip ---- */

.ai-welcome-tip {
    display: flex;
    align-items: flex-start;
    gap: var(--spacing-sm);
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.08), rgba(255, 140, 0, 0.05));
    border: 1px solid rgba(255, 215, 0, 0.2);
    border-radius: 0.75rem;
    padding: 0.75rem var(--spacing-md);
    margin-bottom: 0.75rem;
    animation: tipFadeIn 0.5s ease;
}

.welcome-tip-icon {
    font-size: var(--font-2xl);
    flex-shrink: 0;
    animation: bounceDown 1.5s ease infinite;
}

@keyframes bounceDown {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(5px); }
}

.welcome-tip-text {
    color: #ccc;
    font-size: var(--font-xs);
    line-height: 1.6;
}

.welcome-tip-text b {
    color: #ffd700;
}

/* ---- Quick Actions Hint ---- */

.quick-actions-hint {
    color: #999;
    font-size: 0.8em;
    text-align: center;
    margin-bottom: 0.375rem;
    width: 100%;
}

.quick-actions-btns {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
    justify-content: center;
}

/* ---- Input Hint ---- */

.input-hint {
    color: #999;
    font-size: 0.78em;
    padding: var(--spacing-xs) var(--spacing-sm);
    background: rgba(255, 215, 0, 0.08);
    border-radius: 0.375rem;
    text-align: center;
    width: 100%;
    animation: hintPulse 3s ease-in-out infinite;
}

@keyframes hintPulse {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

/* ---- Rotating Tip Bar ---- */

.rotating-tip-bar {
    color: #888;
    font-size: 0.78em;
    text-align: center;
    padding: 0.375rem 0.75rem;
    min-height: 1.5em;
    transition: opacity 0.3s ease;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    margin-top: var(--spacing-xs);
}

/* ---- Simplified Input Area ---- */

.ai-input-simple {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.ai-input-top-actions {
    display: flex;
    justify-content: flex-end;
}

.ai-input-simple .ai-input {
    width: 100%;
    box-sizing: border-box;
}

.ai-input-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--spacing-sm);
}

.ai-new-btn {
    padding: 0.375rem var(--spacing-sm);
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 0.5rem;
    color: #999;
    font-size: var(--font-xs);
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.ai-new-btn:hover {
    background: rgba(255, 215, 0, 0.1);
    border-color: rgba(255, 215, 0, 0.3);
    color: #ffd700;
}

/* ---- Responsive ---- */

@media (max-width: 480px) {
    .chat-container {
        width: calc(100% - 2.5rem);
        right: var(--spacing-xl);
        bottom: 5.625rem;
        height: 31.25rem;
    }
}

/* ===== Mobile: 辩论/聊天区全宽（百分比 padding 自适应） ===== */
@media (max-width: 768px) {
    .ai-section {
        padding: 1%;
        margin-top: 2%;
        border: none;
        border-radius: 0;
        background: transparent;
    }

    .ai-chat-window {
        padding: 1%;
        min-height: 300px;
        max-height: 60vh;
    }

    .ai-container {
        height: auto;
        min-height: 400px;
    }

    .ai-controls-area {
        padding: 1%;
    }
}

@media (max-width: 480px) {
    .ai-section {
        padding: 0.5%;
    }

    .ai-chat-window {
        padding: 0.5%;
        min-height: 250px;
        max-height: 50vh;
    }

    .ai-container {
        min-height: 350px;
    }
}
