/* ===== 全局变量 ===== */
:root {
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --secondary-gradient: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --success-gradient: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    --dark-bg: #0f0f1a;
    --darker-bg: #0a0a12;
    --sidebar-bg: #0d0d18;
    --card-bg: rgba(255, 255, 255, 0.03);
    --card-hover: rgba(255, 255, 255, 0.06);
    --border-color: rgba(255, 255, 255, 0.08);
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.6);
    --text-muted: rgba(255, 255, 255, 0.4);
    --accent-purple: #a855f7;
    --accent-pink: #ec4899;
    --accent-blue: #3b82f6;
    --accent-cyan: #06b6d4;
    --shadow-lg: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 40px rgba(168, 85, 247, 0.3);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-window: 16px;
}

/* ===== 通用工具类 ===== */

/* 图标按钮基类：.collapse-btn, .expand-sidebar-btn, .header-btn, .popup-close */
.icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}
.icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

/* 输入框基类：.date-input, .config-input, .chat-history-input, .prompt-textarea */
.input-base {
    width: 100%;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font-size: 13px;
    color: var(--text-primary);
    transition: all 0.3s ease;
    font-family: inherit;
}
.input-base::placeholder {
    color: var(--text-muted);
}

/* 焦点环：统一 focus 样式 */
.focus-ring:focus {
    outline: none;
    border-color: var(--accent-purple);
    box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.15);
}

/* 悬浮提升按钮 */
.btn-lift:hover {
    transform: translateY(-2px);
}
.btn-lift:active {
    transform: translateY(0);
}

/* ===== 重置样式 ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f0f1a 100%);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow: hidden;
}

/* ===== 聊天窗口容器 ===== */
.chat-window {
    width: 1400px;
    height: 1200px;
    max-width: calc(100vw - 40px);
    max-height: calc(100vh - 40px);
    display: flex;
    background: var(--dark-bg);
    border-radius: var(--radius-window);
    box-shadow:
        0 50px 100px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(255, 255, 255, 0.05),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
    overflow: hidden;
    position: relative;
}

/* ===== 左侧设置栏 ===== */
.sidebar {
    width: 380px;
    min-width: 380px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: transform 0.3s ease, opacity 0.3s ease;
}
.sidebar.collapsed {
    transform: translateX(-100%);
    opacity: 0;
    width: 0;
    min-width: 0;
}

.sidebar-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}
.logo-icon {
    font-size: 24px;
    animation: float 3s ease-in-out infinite;
}
.logo-text {
    font-size: 16px;
    font-weight: 600;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.collapse-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    color: var(--text-muted);
    font-size: 14px;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.sidebar-section {
    padding: 16px 20px;
}

.section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.section-icon {
    font-size: 12px;
}

/* 对话记录输入框 */
.chat-history-input {
    height: 120px;
    border-radius: var(--radius-md);
    padding: 12px;
    resize: none;
    line-height: 1.5;
}

/* 时间输入 */
.time-inputs {
    display: flex;
    gap: 10px;
}
.input-group {
    flex: 1;
}
.input-group label {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

/* API 配置 */
.api-config {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.password-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}
.password-input-wrapper .config-input {
    padding-right: 40px;
}

.toggle-password {
    position: absolute;
    right: 10px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    opacity: 0.6;
    transition: opacity 0.2s;
}
.toggle-password:hover {
    opacity: 1;
}

.save-config-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--primary-gradient);
    border: none;
    border-radius: var(--radius-md);
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 500;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 4px;
}
.save-config-btn:hover {
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

/* 状态指示器 */
.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
}
.status-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
}
.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ef4444;
    transition: all 0.3s ease;
}
.status-dot.configured {
    background: #22c55e;
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.5);
}
.status-text {
    font-size: 12px;
    color: var(--text-secondary);
}

/* ===== 主聊天区域 ===== */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    background: linear-gradient(180deg, rgba(15, 15, 26, 1) 0%, rgba(10, 10, 18, 1) 100%);
}

/* 聊天头部 */
.chat-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 16px;
    background: rgba(0, 0, 0, 0.2);
}

.expand-sidebar-btn {
    display: none;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    color: var(--text-muted);
    font-size: 16px;
}

.chat-header-info {
    flex: 1;
}
.chat-header-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}
.chat-header-subtitle {
    font-size: 12px;
    color: var(--text-muted);
}

.chat-header-actions {
    display: flex;
    gap: 8px;
}

.header-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    color: var(--text-muted);
    font-size: 16px;
}

/* 聊天容器 */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

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

.chat-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: var(--text-muted);
}
.chat-empty-icon {
    font-size: 56px;
    opacity: 0.2;
}

/* 发送的消息气泡 */
.message-bubble {
    display: flex;
    justify-content: flex-end;
    align-self: flex-end;
    animation: messageIn 0.3s ease;
}
.message-bubble > div {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    max-width: 65%;
}
.message-content {
    padding: 12px 16px;
    background: var(--primary-gradient);
    border-radius: 18px 18px 4px 18px;
    font-size: 14px;
    line-height: 1.5;
    box-shadow: 0 2px 12px rgba(102, 126, 234, 0.25);
}
.message-time {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
    text-align: right;
    padding-right: 4px;
}

/* 输入区域 */
.input-area {
    padding: 16px 24px 20px;
    border-top: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.15);
    position: relative;
}
.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 10px 14px;
    transition: all 0.3s ease;
}
.input-wrapper:focus-within {
    border-color: var(--accent-purple);
    box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.15);
}

.message-input {
    flex: 1;
    background: transparent;
    border: none;
    font-size: 14px;
    color: var(--text-primary);
    resize: none;
    max-height: 100px;
    line-height: 1.5;
    font-family: inherit;
}
.message-input::placeholder {
    color: var(--text-muted);
}
.message-input:focus {
    outline: none;
}

.send-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-gradient);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    flex-shrink: 0;
}
.send-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.4);
}
.send-btn:active {
    transform: scale(0.95);
}
.send-icon {
    color: white;
    font-size: 16px;
}

/* 操作按钮区 */
.action-buttons {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
}
.action-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    border: none;
    border-radius: var(--radius-lg);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}
.action-btn::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255, 255, 255, 0.1);
    opacity: 0;
    transition: opacity 0.3s;
}
.action-btn:hover::before {
    opacity: 1;
}

.quick-btn {
    background: var(--primary-gradient);
    color: white;
}
.quick-btn:hover {
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.35);
}

.follow-btn {
    background: var(--secondary-gradient);
    color: white;
}
.follow-btn:hover {
    box-shadow: 0 6px 20px rgba(240, 147, 251, 0.35);
}

.btn-icon {
    font-size: 15px;
}

/* 加载指示器 */
.loading-indicator {
    display: none;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 13px;
    margin-left: auto;
}
.loading-indicator.active {
    display: flex;
}
.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--border-color);
    border-top-color: var(--accent-purple);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* ===== 私信推荐弹窗 ===== */
.suggestions-popup {
    position: fixed;
    width: 520px;
    max-height: 420px;
    background: rgba(15, 15, 26, 0.95);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-lg);
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.5),
        0 0 40px rgba(168, 85, 247, 0.1);
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px) scale(0.98);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.suggestions-popup.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.popup-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.02);
}
.popup-icon {
    font-size: 14px;
}
.popup-title {
    flex: 1;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}
.popup-close {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    color: var(--text-muted);
    font-size: 12px;
}

.popup-content {
    padding: 10px;
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

/* 推荐私信气泡 */
.suggestion-bubble {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    margin-bottom: 8px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
    animation: bubbleIn 0.25s ease backwards;
    animation-delay: var(--delay, 0s);
}
.suggestion-bubble:hover {
    background: rgba(168, 85, 247, 0.12);
    border-color: rgba(168, 85, 247, 0.3);
    transform: translateX(3px);
}
.suggestion-bubble:active {
    transform: translateX(1px) scale(0.99);
}

.suggestion-number {
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-gradient);
    border-radius: 50%;
    font-size: 11px;
    font-weight: 600;
    flex-shrink: 0;
}
.suggestion-text {
    flex: 1;
    font-size: 13px;
    line-height: 1.45;
    color: var(--text-primary);
}
.suggestion-bubble:last-child {
    margin-bottom: 0;
}

/* 等待/已发送状态 */
.suggestion-bubble.waiting {
    animation: pulse 1s ease-in-out infinite;
}
.suggestion-bubble.sent {
    animation: none;
    opacity: 0.7;
    padding-right: 32px;
}
.suggestion-bubble.sent .suggestion-number {
    background: #22c55e;
}
.suggestion-bubble.sent::after {
    content: '\2713';
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #22c55e;
    font-size: 14px;
    font-weight: bold;
}

/* 风格信息 */
.style-info {
    margin-top: 8px;
    padding: 8px 12px;
    background: rgba(168, 85, 247, 0.08);
    border-radius: var(--radius-sm);
    font-size: 11px;
    color: var(--text-secondary);
}

/* 弹窗底部 */
.popup-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.02);
    display: flex !important;
    flex-direction: column;
    gap: 10px;
    flex-shrink: 0;
}

.send-all-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px 20px;
    background: var(--success-gradient);
    border: none;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 600;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
}
.send-all-btn:hover {
    box-shadow: 0 6px 20px rgba(79, 172, 254, 0.4);
}
.send-all-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* 发送进度 */
.send-progress {
    display: none;
    flex-direction: column;
    gap: 6px;
}
.send-progress.active {
    display: flex;
}
.progress-bar {
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    width: 0%;
    background: var(--success-gradient);
    border-radius: 3px;
    transition: width 0.3s ease;
}
.progress-text {
    font-size: 12px;
    color: var(--text-secondary);
    text-align: center;
}

/* ===== Toast 通知 ===== */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 1000;
}
.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    background: var(--darker-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    animation: toastIn 0.3s ease;
    min-width: 200px;
}
.toast.success { border-color: #22c55e; }
.toast.error { border-color: #ef4444; }
.toast-icon { font-size: 16px; }
.toast-message { font-size: 13px; color: var(--text-primary); }

/* ===== 提示词配置 ===== */
.prompt-config {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.prompt-group {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--card-bg);
}
.prompt-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: rgba(255, 255, 255, 0.02);
}
.prompt-header:hover {
    background: rgba(255, 255, 255, 0.05);
}
.prompt-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
}
.prompt-toggle {
    font-size: 10px;
    color: var(--text-muted);
    transition: transform 0.2s ease;
}

.prompt-content {
    max-height: 400px;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease, opacity 0.3s ease;
    padding: 12px;
    opacity: 1;
}
.prompt-content.collapsed {
    max-height: 0;
    padding: 0 12px;
    opacity: 0;
    border-top: none;
}

.prompt-textarea {
    height: 250px;
    background: var(--darker-bg);
    border-radius: var(--radius-sm);
    padding: 12px;
    font-size: 11px;
    resize: vertical;
    font-family: 'Consolas', 'Monaco', monospace;
    line-height: 1.5;
}

.reset-prompts-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 10px 20px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
}
.reset-prompts-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.15);
}

/* ===== 滚动条 ===== */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.08); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.15); }

/* ===== 动画 ===== */
@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}
@keyframes messageIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes bubbleIn {
    from { opacity: 0; transform: translateX(15px); }
    to { opacity: 1; transform: translateX(0); }
}
@keyframes spin {
    to { transform: rotate(360deg); }
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}
@keyframes toastIn {
    from { opacity: 0; transform: translateX(80px); }
    to { opacity: 1; transform: translateX(0); }
}

/* ===== 响应式 ===== */
@media (max-width: 1500px) {
    .chat-window {
        width: calc(100vw - 40px);
        height: calc(100vh - 40px);
    }
}

@media (max-width: 1000px) {
    .sidebar {
        position: absolute;
        left: 0; top: 0; bottom: 0;
        z-index: 200;
        box-shadow: 4px 0 30px rgba(0, 0, 0, 0.5);
    }
    .sidebar.collapsed {
        transform: translateX(-100%);
    }
    .expand-sidebar-btn {
        display: flex;
    }
    .suggestions-popup {
        max-width: none;
    }
}

@media (max-width: 600px) {
    body { padding: 0; }
    .chat-window {
        width: 100vw;
        height: 100vh;
        max-width: 100vw;
        max-height: 100vh;
        border-radius: 0;
    }
    .sidebar { width: 100%; }
}
