/**
 * NISHOW 通用样式 - Gemini 风格
 * 所有页面共享的基础样式、主题变量、侧边栏布局
 */

/* ========== CSS 变量 - 暗色主题（默认） ========== */
:root {
    --bg-primary: #131314;
    --bg-secondary: #1e1f20;
    --bg-tertiary: #282a2c;
    --bg-hover: #3c4043;
    --bg-input: #1e1f20;

    --text-primary: #e3e3e3;
    --text-secondary: #9aa0a6;
    --text-tertiary: #6e7479;
    --text-placeholder: #6e7479;

    --border-color: #3c4043;
    --border-light: #5f6368;

    --accent-primary: #8ab4f8;
    --accent-secondary: #aecbfa;
    --accent-gradient: linear-gradient(135deg, #4285f4 0%, #9b72cb 50%, #d96570 100%);

    --success-color: #34a853;
    --warning-color: #fbbc05;
    --danger-color: #ea4335;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);

    --sidebar-width: 260px;
    --header-height: 56px;
    --content-max-width: 1200px;
}

/* ========== 亮色主题 ========== */
[data-theme="light"] {
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-tertiary: #f1f3f4;
    --bg-hover: #e8eaed;
    --bg-input: #f8f9fa;

    --text-primary: #202124;
    --text-secondary: #5f6368;
    --text-tertiary: #80868b;
    --text-placeholder: #9aa0a6;

    --border-color: #e0e0e0;
    --border-light: #dadce0;

    --accent-primary: #1a73e8;
    --accent-secondary: #4285f4;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.15);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.2);
}

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

html, body {
    height: 100%;
}

body {
    font-family: 'Google Sans', 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    display: flex;
    overflow: hidden;
    line-height: 1.5;
}

a {
    color: var(--accent-primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* ========== 可访问性 ========== */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
        animation: none !important;
        scroll-behavior: auto !important;
    }
}

/* ========== 侧边栏 ========== */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    height: 100dvh;
    background-color: var(--bg-secondary);
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-color);
    transition: transform 0.3s ease, width 0.3s ease;
    z-index: 100;
    flex-shrink: 0;
}

.sidebar.collapsed {
    transform: translateX(-100%);
    width: 0;
    overflow: hidden;
}

.sidebar-overlay {
    display: none;
}

.sidebar-header {
    padding: 16px;
}

.btn-new-chat {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 16px;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
    text-decoration: none;
}

.btn-new-chat:hover {
    background-color: var(--bg-hover);
    text-decoration: none;
}

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

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 24px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    margin-bottom: 4px;
    transition: all 0.2s;
}

.nav-item:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
    text-decoration: none;
}

.nav-item.active {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

.nav-item i {
    font-size: 18px;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn-theme {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background-color: var(--bg-tertiary);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all 0.2s;
}

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

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
    text-decoration: none;
    color: inherit;
    padding: 6px 8px;
    border-radius: 8px;
    transition: background-color 0.2s;
}

.sidebar-user:hover {
    background-color: var(--bg-hover);
    text-decoration: none;
}

.sidebar-user .user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.sidebar-user .user-name {
    font-size: 14px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ========== 主内容区 ========== */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    min-width: 0;
}

/* ========== 顶部栏 ========== */
.top-bar {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 16px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.btn-menu {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    margin-right: 8px;
}

.btn-menu:hover {
    background-color: var(--bg-hover);
}

.page-title {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-primary);
}

.top-bar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 12px;
}

.credits-display {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background-color: var(--bg-tertiary);
    border-radius: 16px;
    font-size: 13px;
    color: var(--text-secondary);
    text-decoration: none;
}

.credits-display:hover {
    opacity: 0.8;
    text-decoration: none;
}

.credits-display i {
    color: #f9ab00;
}

.credits-label {
    margin-left: 2px;
}

.btn-login {
    padding: 8px 20px;
    background-color: var(--accent-primary);
    color: #000;
    border-radius: 20px;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: opacity 0.2s;
}

.btn-login:hover {
    opacity: 0.9;
    text-decoration: none;
}

[data-theme="light"] .btn-login {
    color: #fff;
}

.btn-register {
    padding: 8px 18px;
    border: 1px solid var(--border-light);
    color: var(--text-primary);
    border-radius: 20px;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    background: transparent;
    transition: background-color 0.2s, border-color 0.2s;
}

.btn-register:hover {
    background-color: var(--bg-hover);
    text-decoration: none;
}

.user-menu {
    display: flex;
    align-items: center;
    text-decoration: none;
}

.user-avatar-small {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    cursor: pointer;
    transition: opacity 0.2s;
}

.user-avatar-small:hover {
    opacity: 0.8;
}

/* ========== 内容滚动区 ========== */
.content-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.content-wrapper {
    max-width: var(--content-max-width);
    margin: 0 auto;
}

/* ========== 卡片 ========== */
.card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 24px;
}

.card-title {
    font-size: 18px;
    font-weight: 500;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-title i {
    color: var(--accent-primary);
}

/* ========== 表单元素 ========== */
.form-group {
    margin-bottom: 20px;
}

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

.form-control {
    width: 100%;
    padding: 12px 16px;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 14px;
    transition: border-color 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.form-control::placeholder {
    color: var(--text-placeholder);
}

.form-select {
    width: 100%;
    padding: 12px 16px;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%239aa0a6' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14L2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 40px;
}

.form-select:focus {
    outline: none;
    border-color: var(--accent-primary);
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

/* ========== 按钮 ========== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: 24px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    text-decoration: none;
}

.btn-primary {
    background-color: var(--accent-primary);
    color: #000;
}

[data-theme="light"] .btn-primary {
    color: #fff;
}

.btn-primary:hover {
    opacity: 0.9;
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary {
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background-color: var(--bg-hover);
}

.btn-gradient {
    width: 100%;
    padding: 14px 24px;
    background: var(--accent-gradient);
    border: none;
    border-radius: 24px;
    color: #fff;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.2s;
}

.btn-gradient:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.btn-gradient:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ========== 标签/徽章 ========== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    background-color: var(--bg-tertiary);
    border-radius: 12px;
    font-size: 12px;
    color: var(--text-secondary);
}

.badge-primary {
    background-color: var(--accent-primary);
    color: #000;
}

[data-theme="light"] .badge-primary {
    color: #fff;
}

/* ========== 上传区域 ========== */
.upload-zone {
    border: 2px dashed var(--border-color);
    border-radius: 16px;
    padding: 32px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.upload-zone:hover {
    border-color: var(--accent-primary);
    background-color: var(--bg-tertiary);
}

.upload-zone.dragover {
    border-color: var(--accent-primary);
    background-color: var(--bg-tertiary);
}

.upload-icon {
    font-size: 48px;
    color: var(--text-tertiary);
    margin-bottom: 12px;
}

.upload-text {
    color: var(--text-secondary);
    font-size: 14px;
}

.upload-text strong {
    color: var(--accent-primary);
}

/* ========== 图片预览 ========== */
.image-preview-container {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 16px;
}

.image-preview-item {
    position: relative;
    width: 100px;
    height: 100px;
}

.image-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.image-preview-item .preview-number {
    position: absolute;
    top: 4px;
    left: 4px;
    background-color: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 2px 8px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
}

.image-preview-item .btn-remove {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background-color: var(--danger-color);
    border: 2px solid var(--bg-primary);
    color: #fff;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

.image-preview-item .btn-remove:hover {
    transform: scale(1.1);
}

/* ========== 标签选择 ========== */
.tag-group {
    margin-bottom: 20px;
}

.tag-group-label {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tag-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag-item {
    padding: 8px 16px;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.tag-item:hover {
    border-color: var(--accent-primary);
    color: var(--text-primary);
}

.tag-item.active {
    background-color: var(--accent-primary);
    border-color: var(--accent-primary);
    color: #000;
}

[data-theme="light"] .tag-item.active {
    color: #fff;
}

/* ========== 分隔线 ========== */
.divider {
    height: 1px;
    background-color: var(--border-color);
    margin: 20px 0;
}

/* ========== 折叠区域 ========== */
.collapsible-section {
    margin-top: 20px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
}

.collapsible-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    background-color: var(--bg-tertiary);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    transition: background-color 0.2s;
}

.collapsible-header:hover {
    background-color: var(--bg-hover);
}

.collapsible-header i:first-child {
    margin-right: 8px;
    color: var(--accent-primary);
}

.collapse-icon {
    transition: transform 0.3s;
}

.collapsible-header.active .collapse-icon {
    transform: rotate(180deg);
}

.collapsible-content {
    padding: 20px;
    display: none;
}

.collapsible-content.show {
    display: block;
}

/* ========== 结果区域 ========== */
.result-container {
    min-height: 200px;
}

.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-tertiary);
}

.empty-state i {
    font-size: 48px;
    margin-bottom: 16px;
    display: block;
}

.empty-state p {
    font-size: 14px;
}

/* ========== 加载状态 ========== */
.spinner-container {
    display: none;
    text-align: center;
    padding: 24px;
}

.spinner-container.show {
    display: block;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

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

.spinner-container p {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 4px;
}

.spinner-container small {
    color: var(--text-tertiary);
    font-size: 12px;
}

/* ========== 提示信息 ========== */
.alert {
    padding: 12px 16px;
    border-radius: 12px;
    margin-bottom: 16px;
    display: flex;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 6px;
    font-size: 14px;
    line-height: 1.6;
}

.alert > i:first-child {
    flex-shrink: 0;
    margin-top: 2px;
}

.alert-info {
    background-color: rgba(138, 180, 248, 0.1);
    border: 1px solid rgba(138, 180, 248, 0.3);
    color: var(--accent-primary);
}

.alert-success {
    background-color: rgba(52, 168, 83, 0.1);
    border: 1px solid rgba(52, 168, 83, 0.3);
    color: var(--success-color);
}

.alert-warning {
    background-color: rgba(251, 188, 5, 0.1);
    border: 1px solid rgba(251, 188, 5, 0.3);
    color: var(--warning-color);
}

.alert-danger {
    background-color: rgba(234, 67, 53, 0.1);
    border: 1px solid rgba(234, 67, 53, 0.3);
    color: var(--danger-color);
}

/* ========== 表格 ========== */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.data-table th {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.data-table td {
    font-size: 14px;
    color: var(--text-primary);
}

.data-table tr:hover td {
    background-color: var(--bg-tertiary);
}

/* ========== 分页 ========== */
.pagination {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-top: 20px;
}

.page-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background-color: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.page-btn:hover {
    border-color: var(--accent-primary);
    color: var(--text-primary);
}

.page-btn.active {
    background-color: var(--accent-primary);
    border-color: var(--accent-primary);
    color: #000;
}

[data-theme="light"] .page-btn.active {
    color: #fff;
}

/* ========== 两栏布局 ========== */
.layout-row {
    display: flex;
    gap: 24px;
}

.layout-col-main {
    flex: 1;
    min-width: 0;
}

.layout-col-side {
    width: 320px;
    flex-shrink: 0;
}

/* ========== 弹窗 ========== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background-color: var(--bg-secondary);
    border-radius: 24px;
    width: 90%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

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

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

.btn-close-modal {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

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

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* ========== 图片查看器 ========== */
.image-viewer {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.image-viewer img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
}

.viewer-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background-color: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.viewer-close:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.viewer-actions {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 12px;
}

.viewer-actions button {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    background-color: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.viewer-actions button:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

/* ========== 实时统计 ========== */
.info-display {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: 12px;
}

.info-item {
    text-align: center;
    padding: 12px;
    background-color: var(--bg-tertiary);
    border-radius: 12px;
}

.info-label {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-bottom: 4px;
}

.info-value {
    font-size: 20px;
    font-weight: 500;
    color: var(--text-primary);
}

/* ========== 滚动条 ========== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background-color: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background-color: var(--border-light);
}

/* ========== 响应式 ========== */
@media (max-width: 1024px) {
    .layout-row {
        flex-direction: column;
    }

    .layout-col-side {
        width: 100%;
    }
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        transform: translateX(-100%);
    }

    .sidebar.collapsed {
        width: var(--sidebar-width);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background-color: rgba(0, 0, 0, 0.55);
        display: none;
        z-index: 90;
    }

    .sidebar.open ~ .sidebar-overlay {
        display: block;
    }

    .content-scroll {
        padding: 16px;
    }

    .card {
        padding: 16px;
    }
}
