/* ============================================================
   卖家精灵数据助手 — 样式表
   ============================================================ */

:root {
    --bg-primary: #0f0f14;
    --bg-secondary: #1a1a24;
    --bg-tertiary: #24243a;
    --bg-hover: #2a2a42;
    --surface: #1e1e30;
    --border: #2d2d48;
    --border-light: #3d3d5c;
    --text-primary: #e8e8f0;
    --text-secondary: #a0a0b8;
    --text-muted: #6b6b84;
    --accent: #6366f1;
    --accent-hover: #818cf8;
    --accent-light: rgba(99, 102, 241, 0.15);
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --radius: 10px;
    --radius-lg: 16px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --transition: all 0.2s ease;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ============================================================
   登录页面
   ============================================================ */

.login-screen {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    background-image:
        radial-gradient(circle at 20% 30%, rgba(99, 102, 241, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 80% 70%, rgba(139, 92, 246, 0.06) 0%, transparent 50%);
}

.login-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 48px 40px;
    width: 400px;
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.login-logo { margin-bottom: 20px; }

.login-card h1 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.login-subtitle {
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 32px;
}

.form-group {
    margin-bottom: 20px;
    text-align: left;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-group input[type="text"],
.form-group input[type="password"] {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
    font-family: var(--font);
    transition: var(--transition);
    outline: none;
}

.form-group input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.btn-primary {
    width: 100%;
    padding: 12px;
    background: var(--gradient);
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 15px;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    transition: var(--transition);
}

.btn-primary:hover { opacity: 0.9; transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.error-text {
    color: var(--danger);
    font-size: 13px;
    margin-top: 12px;
    min-height: 20px;
}

/* ============================================================
   主界面布局
   ============================================================ */

.main-screen {
    display: flex;
    height: 100vh;
}

/* ============================================================
   侧边栏
   ============================================================ */

.sidebar {
    width: 280px;
    min-width: 280px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px;
    border-bottom: 1px solid var(--border);
}

.logo-text {
    font-size: 16px;
    font-weight: 700;
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.btn-new-chat {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 16px;
    padding: 10px;
    background: var(--accent-light);
    border: 1px dashed var(--accent);
    border-radius: 8px;
    color: var(--accent-hover);
    font-size: 14px;
    font-weight: 500;
    font-family: var(--font);
    cursor: pointer;
    transition: var(--transition);
}

.btn-new-chat:hover {
    background: rgba(99, 102, 241, 0.25);
}

.conversation-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 12px;
}

.conversation-list::-webkit-scrollbar { width: 4px; }
.conversation-list::-webkit-scrollbar-track { background: transparent; }
.conversation-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.conv-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    margin-bottom: 4px;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
    font-size: 13px;
    color: var(--text-secondary);
}

.conv-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.conv-item.active { background: var(--accent-light); color: var(--accent-hover); }

.conv-item .conv-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.conv-item .conv-delete {
    opacity: 0;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 16px;
    padding: 2px 6px;
    border-radius: 4px;
    transition: var(--transition);
}

.conv-item:hover .conv-delete { opacity: 1; }
.conv-item .conv-delete:hover { color: var(--danger); background: rgba(239, 68, 68, 0.15); }
.conv-item .conv-delete.confirming {
    opacity: 1 !important;
    background: var(--danger) !important;
    color: white !important;
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 500;
}

.sidebar-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-top: 1px solid var(--border);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    color: white;
}

.sidebar-actions { display: flex; gap: 4px; }

.btn-icon {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    transition: var(--transition);
    display: flex;
    align-items: center;
}

.btn-icon:hover { background: var(--bg-hover); color: var(--text-primary); }

/* ============================================================
   聊天区域
   ============================================================ */

.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: relative;
}

/* 队列横幅 */
.queue-banner {
    background: linear-gradient(90deg, rgba(245, 158, 11, 0.12), rgba(245, 158, 11, 0.06));
    border-bottom: 1px solid rgba(245, 158, 11, 0.25);
    padding: 10px 20px;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from { transform: translateY(-100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.queue-banner-content {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: var(--warning);
}

.queue-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(245, 158, 11, 0.3);
    border-top-color: var(--warning);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* 消息列表 */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 24px 0;
}

.messages-container::-webkit-scrollbar { width: 6px; }
.messages-container::-webkit-scrollbar-track { background: transparent; }
.messages-container::-webkit-scrollbar-thumb { background: var(--border); border-radius: 6px; }

.welcome-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 40px 24px;
    max-width: 820px;
    margin: 0 auto;
    overflow-y: auto;
}

.welcome-icon { margin-bottom: 20px; }

.welcome-screen h2 {
    font-size: 26px;
    font-weight: 700;
    margin-bottom: 10px;
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.welcome-desc {
    color: var(--text-secondary);
    font-size: 15px;
    margin-bottom: 28px;
    max-width: 560px;
    line-height: 1.6;
}

/* 能力卡片 */
.feature-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    width: 100%;
    margin-bottom: 32px;
}

.feature-card {
    padding: 20px 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    text-align: center;
    transition: var(--transition);
}

.feature-card:hover {
    border-color: var(--accent);
    background: var(--bg-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.1);
}

.feature-icon {
    font-size: 28px;
    margin-bottom: 10px;
}

.feature-card h4 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.feature-card p {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.5;
    margin-bottom: 0;
}

/* 分类示例 */
.example-sections {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    text-align: left;
}

.example-section {
    padding: 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
}

.example-section h5 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.example-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.quick-btn {
    padding: 9px 14px;
    background: var(--bg-tertiary);
    border: 1px solid transparent;
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 13px;
    font-family: var(--font);
    cursor: pointer;
    transition: var(--transition);
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.quick-btn:hover {
    background: var(--accent-light);
    border-color: var(--accent);
    color: var(--accent-hover);
}

/* 消息气泡 */
.message {
    max-width: 780px;
    margin: 0 auto;
    padding: 0 24px;
    margin-bottom: 24px;
    animation: fadeIn 0.3s ease;
}

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

.message-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.message-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    flex-shrink: 0;
}

.message-avatar.user-msg { background: var(--gradient); color: white; }
.message-avatar.bot-msg { background: linear-gradient(135deg, #22c55e, #16a34a); color: white; }

.message-sender {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.message-body {
    padding-left: 38px;
    font-size: 14px;
    line-height: 1.7;
    color: var(--text-primary);
}

.message-body p { margin-bottom: 8px; }
.message-body p:last-child { margin-bottom: 0; }

.message-body strong { color: var(--accent-hover); }

.message-body code {
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
}

.message-body pre {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px;
    overflow-x: auto;
    margin: 10px 0;
    font-size: 13px;
    line-height: 1.5;
}

.message-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 10px 0;
    font-size: 13px;
}

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

.message-body th {
    background: var(--bg-tertiary);
    font-weight: 600;
    color: var(--accent-hover);
}

.message-body ul, .message-body ol {
    padding-left: 20px;
    margin: 8px 0;
}

.message-body li { margin-bottom: 4px; }

.tool-status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--accent-hover);
    background: rgba(99, 102, 241, 0.08);
    border: 1px dashed rgba(99, 102, 241, 0.4);
    padding: 6px 12px;
    border-radius: 6px;
    margin-top: 10px;
    font-style: italic;
}

/* 思考中动画 */
.thinking-dots {
    display: flex;
    gap: 4px;
    padding-left: 38px;
}

.thinking-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    animation: bounce 1.4s ease-in-out infinite;
}

.thinking-dots span:nth-child(1) { animation-delay: 0s; }
.thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* 排队提示 */
.queued-notice {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    padding-left: 38px;
    color: var(--warning);
    font-size: 13px;
}

/* ============================================================
   输入区
   ============================================================ */

.input-area {
    padding: 16px 24px 20px;
    max-width: 780px;
    margin: 0 auto;
    width: 100%;
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 10px 14px;
    transition: var(--transition);
}

.input-wrapper:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.input-wrapper textarea {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 14px;
    font-family: var(--font);
    line-height: 1.5;
    resize: none;
    outline: none;
    max-height: 150px;
}

.input-wrapper textarea::placeholder { color: var(--text-muted); }

.btn-send {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--gradient);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: var(--transition);
}

.btn-send:hover { opacity: 0.9; }
.btn-send:disabled { opacity: 0.3; cursor: not-allowed; }

.input-hint {
    text-align: center;
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 8px;
}

/* ============================================================
   管理后台弹窗
   ============================================================ */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease;
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-height: 80vh;
    overflow-y: auto;
}

.admin-modal {
    width: 700px;
    padding: 24px;
}

.small-modal {
    width: 400px;
    padding: 24px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 700;
}

.btn-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: var(--transition);
}

.btn-close:hover { background: var(--bg-hover); color: var(--text-primary); }

.admin-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    padding: 4px;
}

.tab-btn {
    flex: 1;
    padding: 8px 16px;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    font-family: var(--font);
    cursor: pointer;
    transition: var(--transition);
}

.tab-btn.active {
    background: var(--accent);
    color: white;
}

.admin-toolbar {
    margin-bottom: 16px;
}

.btn-small {
    padding: 8px 16px;
    font-size: 13px;
    border-radius: 6px;
    font-family: var(--font);
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.btn-small.btn-primary {
    width: auto;
    background: var(--gradient);
    border: none;
    color: white;
}

.admin-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.admin-user-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.admin-user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.admin-user-details h4 { font-size: 14px; font-weight: 600; }
.admin-user-details p { font-size: 12px; color: var(--text-muted); }

.admin-user-actions {
    display: flex;
    gap: 6px;
}

.badge {
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}

.badge-admin { background: rgba(99, 102, 241, 0.2); color: var(--accent-hover); }
.badge-active { background: rgba(34, 197, 94, 0.15); color: var(--success); }
.badge-inactive { background: rgba(239, 68, 68, 0.15); color: var(--danger); }

.btn-toggle, .btn-delete-user {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 12px;
    font-family: var(--font);
    cursor: pointer;
    transition: var(--transition);
}

.btn-toggle:hover { background: var(--bg-hover); }
.btn-delete-user:hover { background: rgba(239, 68, 68, 0.15); color: var(--danger); border-color: var(--danger); }

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.checkbox-group input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
}

.checkbox-group label { margin-bottom: 0; }

/* 统计卡片 */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.stat-card {
    padding: 16px;
    background: var(--bg-tertiary);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.stat-card .stat-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.stat-card .stat-value {
    font-size: 28px;
    font-weight: 700;
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* ============================================================
   工具展示弹窗
   ============================================================ */

.tools-modal {
    width: 850px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    max-height: 85vh;
}

.tools-search-bar {
    margin-bottom: 16px;
    width: 100%;
}

.tools-search-bar input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    outline: none;
    font-size: 14px;
    transition: var(--transition);
}

.tools-search-bar input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
}

.tools-container {
    flex: 1;
    overflow-y: auto;
    padding-right: 4px;
    margin-top: 10px;
}

.tools-container::-webkit-scrollbar { width: 6px; }
.tools-container::-webkit-scrollbar-thumb { background: var(--border); border-radius: 6px; }

.tools-cat-section {
    margin-bottom: 24px;
}

.tools-cat-section h4 {
    font-size: 15px;
    font-weight: 700;
    color: var(--accent);
    border-bottom: 1px solid var(--border);
    padding-bottom: 8px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tools-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.tool-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px;
    transition: var(--transition);
}

.tool-card:hover {
    border-color: var(--accent);
    background: var(--bg-hover);
}

.tool-card-name {
    font-size: 13px;
    font-weight: 600;
    font-family: monospace;
    color: var(--text-primary);
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.tool-card-desc {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.5;
}

/* ============================================================
   响应式
   ============================================================ */

@media (max-width: 768px) {
    .sidebar { display: none; }
    .login-card { width: 90%; padding: 32px 24px; }
    .message { padding: 0 16px; }
    .input-area { padding: 12px 16px; }
    .admin-modal { width: 95%; }
}
