/* AI聚合搜索引擎 - ChatHub 核心布局样式 */

:root {
    --sidebar-width: 280px;
    --sidebar-bg: var(--bg-sidebar, #ffffff);
    --sidebar-border: var(--border-color, #e5e7eb);
    --card-bg: var(--bg-tertiary, #f3f4f6);
    --card-bg-active: var(--bg-primary, #ffffff);
    --primary-color: #4f46e5;
    --text-main: var(--text-primary, #374151);
    --text-muted: var(--text-secondary, #6b7280);
    --border-radius: 12px;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #f8fafc;
}

#app {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* 侧边栏样式重构 */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    padding: 20px 16px;
    box-sizing: border-box;
    border-right: 1px solid #e5e7eb;
    overflow-y: auto;
}

/* 侧边栏折叠状态 */
.sidebar.collapsed {
    width: 80px;
}

.sidebar.collapsed .brand-name,
.sidebar.collapsed .nav-item span:not(.nav-icon),
.sidebar.collapsed .section-title,
.sidebar.collapsed .aio-header span:not(.aio-icon) {
    display: none;
}

.sidebar.collapsed .nav-item {
    justify-content: center;
    padding: 12px;
}

.sidebar.collapsed .all-in-one-card {
    padding: 8px;
}

.sidebar.collapsed .layout-switches {
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-logo {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #4f46e5, #9333ea);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 20px;
}

.brand-name {
    font-size: 22px;
    font-weight: 800;
    color: #1e293b;
    letter-spacing: -0.5px;
}

/* All-In-One 卡片 */
.all-in-one-card {
    background-color: #ffffff;
    border-radius: var(--border-radius);
    padding: 12px;
    margin-bottom: 24px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.aio-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    font-weight: 600;
    color: #1a1a1a;
}

.aio-icon {
    font-size: 18px;
    color: #4f46e5;
}

.layout-switches {
    display: flex;
    justify-content: space-between;
    border-top: 1px solid #f1f5f9;
    padding-top: 12px;
}

.layout-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    color: #94a3b8;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.layout-btn:hover {
    background-color: #f1f5f9;
    color: #4f46e5;
}

.layout-btn.active {
    background-color: #f1f5f9;
    color: #4f46e5;
    border-color: rgba(79, 70, 229, 0.1);
}

.layout-btn svg {
    width: 20px;
    height: 20px;
}

/* 分组标题 */
.section-title {
    font-size: 13px;
    font-weight: 700;
    color: #4b5563;
    margin-bottom: 12px;
    margin-top: 20px;
}

/* 导航项卡片布局 */
.nav-item {
    background-color: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 12px 16px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    color: #374151;
    text-decoration: none;
    font-weight: 500;
    font-size: 14px;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.nav-item:hover {
    background-color: var(--card-bg-active);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.nav-item.active {
    background-color: var(--card-bg-active);
    color: var(--primary-color);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.nav-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 窗口内模型切换下拉 */
.dropdown-container {
    position: relative;
    display: inline-block;
}

.model-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background-color: #ffffff;
    min-width: 160px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    z-index: 1000;
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #e5e7eb;
}

.model-dropdown.show {
    display: block;
}

.dropdown-item {
    padding: 10px 16px;
    font-size: 13px;
    color: #374151;
    cursor: pointer;
    transition: background-color 0.2s;
    white-space: nowrap;
}

.dropdown-item:hover {
    background-color: #f3f4f6;
}

.dropdown-item i {
    margin-right: 8px;
}

/* 图像生成器专用视图 */
.image-gen-view {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 60px !important;
    background-color: #ffffff;
}

.tool-page-container {
    width: 100%;
    max-width: 1200px;
    /* 大幅度增加宽度 */
    text-align: center;
}

.tool-title {
    font-size: 32px;
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 32px;
}

.image-gen-card {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 24px;
    padding: 24px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
}

.gen-prompt {
    width: 100%;
    min-height: 240px;
    /* 增加高度，让输入框显得更长 */
    border: none;
    resize: none;
    font-size: 18px;
    /* 稍微加大字号 */
    color: #374151;
    margin-bottom: 24px;
    line-height: 1.6;
}

.gen-prompt:focus {
    outline: none;
}

.gen-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 12px;
    margin-bottom: 24px;
    border-bottom: 1px solid #f3f4f6;
    /* 增加分隔线 */
    color: #9ca3af;
    font-size: 14px;
}

.gen-meta {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.gen-controls {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.control-group {
    display: flex;
    align-items: center;
}

/* 自定义下拉菜单 */
.custom-select {
    position: relative;
    min-width: 160px;
}

.select-selected {
    background-color: #f3f4f6;
    border-radius: 12px;
    /* 更圆润 */
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border: 1px solid transparent;
    transition: all 0.2s;
}

.select-selected:hover {
    background-color: #e5e7eb;
    border-color: #d1d5db;
}

.select-items {
    position: absolute;
    background-color: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    top: 110%;
    /* 留一点间距 */
    left: 0;
    right: 0;
    z-index: 100;
    display: none;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    padding: 4px;
}

.select-items.show {
    display: block;
    animation: fadeInDown 0.2s ease-out;
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.select-items div {
    padding: 10px 14px;
    cursor: pointer;
    font-size: 14px;
    border-radius: 8px;
}

.select-items div:hover {
    background-color: #f3f4f6;
    color: var(--primary-color);
}

.gen-select {
    background-color: #f3f4f6;
    border: 1px solid transparent;
    border-radius: 12px;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.gen-select:hover {
    background-color: #e5e7eb;
    border-color: #d1d5db;
}

.checkbox-group-inline {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #4b5563;
    font-weight: 500;
}

.checkbox-group-inline input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.btn-history {
    background-color: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-history:hover {
    background-color: #f9fafb;
    border-color: #9ca3af;
}

.btn-generate {
    padding: 10px 32px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 15px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-primary, #ffffff);
}

/* 对话网格模式 */
.chat-grid {
    flex: 1;
    display: grid;
    gap: 12px;
    padding: 12px;
    background-color: #eff3f6;
    overflow-y: auto;
}

.chat-grid.mode-1 {
    grid-template-columns: 1fr;
}

.chat-grid.mode-2 {
    grid-template-columns: 1fr 1fr;
}

.chat-grid.mode-3 {
    grid-template-columns: 1fr 1fr 1fr;
}

.chat-grid.mode-4 {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
}

.chat-grid.mode-6 {
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-rows: 1fr 1fr;
}

.chat-panel {
    background-color: #ffffff;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.panel-header {
    padding: 8px 12px;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
    font-weight: 600;
}

.panel-content {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
}

/* 底部输入框 */
.input-area {
    padding: 0 12px 24px;
    /* 与 chat-grid 的 12px padding 对齐 */
    background-color: var(--bg-primary, #ffffff);
}

.input-container-floating {
    max-width: 100%;
    /* 取消固定宽度限制 */
    margin: 0 auto;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    padding: 8px;
}

.input-rows {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    padding: 4px 12px;
}

.prompt-textarea {
    flex: 1;
    border: none;
    background: transparent;
    resize: none;
    font-size: 15px;
    padding: 8px 0;
    max-height: 200px;
    outline: none;
}

.send-button {
    width: 40px;
    height: 40px;
    background-color: #6b7280;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: not-allowed;
    transition: all 0.2s;
    flex-shrink: 0;
    opacity: 0.6;
}

.send-button.active {
    background-color: #4f46e5;
    cursor: pointer;
    opacity: 1;
}

.send-button.active:hover {
    background-color: #4338ca;
    transform: scale(1.05);
}

.send-button i {
    font-size: 16px;
}

.input-actions {
    display: flex;
    justify-content: space-between;
    padding: 4px 12px;
    border-top: 1px solid #f1f5f9;
}

.tool-icons {
    display: flex;
    gap: 4px;
}

.tool-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6b7280;
    cursor: pointer;
    border-radius: 6px;
}

.tool-icon:hover {
    background-color: #f3f4f6;
}

/* 模态框样式 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
}

.modal.open {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: var(--bg-primary, white);
    border-radius: 16px;
    padding: 32px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    z-index: 10000;
    border: 1px solid var(--sidebar-border, transparent);
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    font-size: 24px;
    color: #9ca3af;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s;
}

.modal-close:hover {
    background: #f3f4f6;
    color: #374151;
}

/* 认证标签 */
.auth-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    border-bottom: 2px solid #f3f4f6;
}

.auth-tab {
    flex: 1;
    padding: 12px;
    background: none;
    border: none;
    font-size: 15px;
    font-weight: 600;
    color: #9ca3af;
    cursor: pointer;
    position: relative;
    transition: color 0.2s;
}

.auth-tab.active {
    color: #4f46e5;
}

.auth-tab.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background: #4f46e5;
}

/* 认证表单 */
.auth-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary, #374151);
}

.form-group input {
    padding: 10px 14px;
    border: 1px solid var(--sidebar-border, #e5e7eb);
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.2s;
    background: var(--bg-tertiary, white);
    color: var(--text-primary);
}

.form-group input:focus {
    outline: none;
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.btn-submit {
    padding: 12px;
    background: white;
    color: #374151;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 8px;
}

.btn-submit:hover {
    background: #f9fafb;
    border-color: #d1d5db;
}

.btn-register-submit {
    background: #4f46e5;
    color: white;
    border: none;
}

.btn-register-submit:hover {
    background: #4338ca;
}

/* 用户按钮悬停效果 */
.btn-register:hover,
.btn-login:hover {
    opacity: 0.9;
    transform: translateY(-1px);
    transition: all 0.2s;
}

#logoutBtn:hover {
    background: #f3f4f6;
    transition: all 0.2s;
}

/* 表单实时校验反馈 */
.form-feedback {
    font-size: 12px;
    margin-top: 4px;
    min-height: 18px;
    transition: all 0.3s ease;
}

.form-feedback.success {
    color: #10b981;
}

.form-feedback.error {
    color: #ef4444;
}

.form-group input.valid {
    border-color: #10b981 !important;
}

.form-group input.invalid {
    border-color: #ef4444 !important;
}

/* ===== 设置面板样式 ===== */
.settings-modal {
    max-width: 420px;
    width: 90%;
    padding: 0;
    border-radius: 16px;
    overflow: hidden;
    border-left: 4px solid #4f9eed;
}

.settings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--sidebar-border, #e5e7eb);
}

.settings-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary, #1f2937);
}

.settings-body {
    padding: 24px;
}

.settings-group {
    margin-bottom: 24px;
}

.settings-group:last-child {
    margin-bottom: 0;
}

.settings-label {
    display: block;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary, #374151);
    margin-bottom: 10px;
}

.settings-tooltip {
    color: #9ca3af;
    font-size: 14px;
    cursor: help;
    margin-left: 4px;
}

.settings-select {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--sidebar-border, #e5e7eb);
    border-radius: 10px;
    font-size: 14px;
    color: var(--text-primary, #374151);
    background-color: var(--bg-tertiary, #f9fafb);
    cursor: pointer;
    transition: all 0.2s;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%239ca3af'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-right: 40px;
}

.settings-select:hover {
    border-color: #d1d5db;
}

.settings-select:focus {
    outline: none;
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.settings-textarea {
    width: 100%;
    min-height: 100px;
    padding: 14px 16px;
    border: 1px solid var(--sidebar-border, #e5e7eb);
    border-radius: 10px;
    font-size: 14px;
    color: var(--text-primary, #374151);
    background-color: var(--bg-tertiary, #f9fafb);
    resize: none;
    line-height: 1.5;
    transition: all 0.2s;
}

.settings-textarea::placeholder {
    color: #9ca3af;
}

.settings-textarea:focus {
    outline: none;
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.settings-char-count {
    text-align: right;
    font-size: 12px;
    color: #9ca3af;
    margin-top: 8px;
}

/* 深色模式下的设置面板 */
.theme-dark .settings-select,
.theme-dark .settings-textarea {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    border-color: var(--border-color);
}

.theme-dark .settings-select:focus,
.theme-dark .settings-textarea:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

/* 模型下拉菜单样式 */
.model-dropdown-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 0 4px;
}

.model-dropdown {
    background: #f3f4f6;
    border-radius: 10px;
    overflow: hidden;
    transition: all 0.2s ease;
    border: 2px solid transparent;
}

.model-dropdown.selected {
    background: #eef2ff;
    border-color: #4f46e5;
}

.model-dropdown-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    cursor: pointer;
    transition: background 0.2s;
}

.model-dropdown-header:hover {
    background: rgba(0, 0, 0, 0.05);
}

.model-dropdown.selected .model-dropdown-header {
    background: rgba(79, 70, 229, 0.1);
}

.model-icon {
    font-size: 16px;
    width: 24px;
    text-align: center;
}

.model-service-name {
    flex: 1;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
}

.model-dropdown.selected .model-service-name {
    color: #4f46e5;
}

.dropdown-arrow {
    font-size: 10px;
    color: #9ca3af;
    transition: transform 0.2s;
}

.model-select {
    width: 100%;
    padding: 8px 12px;
    border: none;
    background: rgba(255, 255, 255, 0.8);
    font-size: 12px;
    color: #6b7280;
    cursor: pointer;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%239ca3af' d='M3 5l3 3 3-3'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 28px;
}

.model-select:focus {
    outline: none;
    background-color: white;
}

.model-dropdown.selected .model-select {
    background-color: rgba(255, 255, 255, 0.9);
    color: #4f46e5;
}

/* 深色模式下的模型下拉菜单 */
.theme-dark .model-dropdown {
    background: var(--bg-secondary);
}

.theme-dark .model-dropdown.selected {
    background: rgba(99, 102, 241, 0.15);
    border-color: #6366f1;
}

.theme-dark .model-dropdown-header:hover {
    background: rgba(255, 255, 255, 0.05);
}

.theme-dark .model-service-name {
    color: var(--text-primary);
}

.theme-dark .model-dropdown.selected .model-service-name {
    color: #a5b4fc;
}

.theme-dark .model-select {
    background-color: var(--bg-primary);
    color: var(--text-secondary);
    border-top-color: var(--border-color);
}

.theme-dark .model-dropdown.selected .model-select {
    color: #a5b4fc;
}