/**
 * 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%);

    --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;
    --input-max-width: 768px;
}

/* ========== 亮色主题 ========== */
[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;
}

/* ========== 可访问性与提示 ========== */
.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;
}

.skip-link {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 2000;
    padding: 10px 14px;
    border-radius: 12px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    text-decoration: none;
    border: 1px solid var(--border-color);
    transform: translateY(-160%);
    transition: transform 0.2s ease;
}

.skip-link:focus {
    transform: translateY(0);
}

.noscript-banner {
    position: fixed;
    top: 12px;
    left: 12px;
    right: 12px;
    z-index: 2000;
    padding: 10px 12px;
    border-radius: 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 13px;
}

: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;
}

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

.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;
}

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

.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);
}

.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);
}

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

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

.user-info .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;
}

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

.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);
}

.model-selector {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.model-selector:hover {
    background-color: var(--bg-hover);
}

.model-name {
    font-size: 16px;
    font-weight: 500;
}

.model-badge {
    font-size: 11px;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 10px;
    background: var(--accent-gradient);
    color: #000;
    margin-left: 4px;
}

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

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

.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);
}

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

.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;
}

[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, opacity 0.2s;
}

.btn-register:hover {
    background-color: var(--bg-hover);
    opacity: 0.95;
}

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

/* ========== 欢迎区域 ========== */
.welcome-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    overflow-y: auto;
}

.welcome-content {
    text-align: center;
    margin-bottom: 48px;
}

.gemini-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 24px;
}

.gemini-icon svg {
    width: 100%;
    height: 100%;
}

.welcome-title {
    font-size: 44px;
    font-weight: 400;
    margin-bottom: 8px;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.welcome-subtitle {
    font-size: 44px;
    font-weight: 400;
    color: var(--text-primary);
}

/* ========== 快捷提示 ========== */
.quick-prompts {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    max-width: 800px;
    justify-content: center;
}

.prompt-card {
    padding: 14px 20px;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
    max-width: 300px;
}

.prompt-card:hover {
    background-color: var(--bg-tertiary);
    border-color: var(--border-light);
    color: var(--text-primary);
}

/* ========== 对话区域 ========== */
.chat-section {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.chat-messages {
    max-width: var(--input-max-width);
    margin: 0 auto;
}

.message {
    margin-bottom: 32px;
}

.message-user {
    display: flex;
    justify-content: flex-end;
}

.message-user .message-content {
    background-color: var(--bg-tertiary);
    padding: 12px 18px;
    border-radius: 20px;
    max-width: 80%;
}

.message-user .message-images {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
    margin-bottom: 8px;
}

.message-user .message-images img {
    max-width: 150px;
    max-height: 150px;
    border-radius: 12px;
    object-fit: cover;
}

.message-ai {
    display: flex;
    gap: 16px;
}

.message-ai .ai-avatar {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
}

.message-ai .ai-avatar svg {
    width: 100%;
    height: 100%;
}

.message-ai .message-content {
    flex: 1;
    min-width: 0;
}

.message-ai .result-image {
    max-width: 100%;
    max-height: 500px;
    border-radius: 12px;
    cursor: pointer;
    transition: transform 0.2s;
}

.message-ai .result-image:hover {
    transform: scale(1.02);
}

.message-ai .result-text {
    margin-top: 12px;
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.6;
}

.message-ai .result-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.message-ai .result-actions button {
    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;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

.message-ai .result-actions button:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

/* 加载动画 */
.loading-dots {
    display: flex;
    gap: 4px;
    padding: 16px 0;
}

.loading-dots span {
    width: 8px;
    height: 8px;
    background-color: var(--text-tertiary);
    border-radius: 50%;
    animation: loadingPulse 1.4s ease-in-out infinite both;
}

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

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

/* ========== 输入区域 ========== */
.input-section {
    padding: 16px 24px 24px;
}

.input-container {
    max-width: var(--input-max-width);
    margin: 0 auto;
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 28px;
    overflow: hidden;
    transition: border-color 0.2s;
}

.input-container:focus-within {
    border-color: var(--accent-primary);
}

/* 图片预览区 */
.image-preview-area {
    padding: 12px 16px 8px;
    border-bottom: 1px solid var(--border-color);
}

.preview-scroll {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.preview-scroll::-webkit-scrollbar {
    height: 4px;
}

.preview-scroll::-webkit-scrollbar-thumb {
    background-color: var(--border-light);
    border-radius: 2px;
}

.preview-item {
    position: relative;
    flex-shrink: 0;
}

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

.preview-item .remove-btn {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.preview-item .remove-btn:hover {
    background-color: #dc3545;
    border-color: #dc3545;
    color: #fff;
}

/* 输入框 */
.input-wrapper {
    padding: 12px 16px;
}

.prompt-input {
    width: 100%;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 16px;
    line-height: 1.5;
    resize: none;
    max-height: 200px;
    min-height: 24px;
}

.prompt-input::placeholder {
    color: var(--text-placeholder);
}

.input-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 8px;
}

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

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

.image-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background-color: var(--bg-tertiary);
    border-radius: 16px;
    font-size: 13px;
    color: var(--accent-primary);
}

.image-indicator i {
    font-size: 14px;
}

.btn-clear-images {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--text-tertiary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    margin-left: 2px;
}

.btn-clear-images:hover {
    color: var(--text-primary);
}

.input-spacer {
    flex: 1;
}

.btn-submit {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background-color: var(--text-tertiary);
    color: var(--bg-primary);
    cursor: not-allowed;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.2s;
}

.btn-submit:not(:disabled) {
    background-color: var(--text-primary);
    cursor: pointer;
}

.btn-submit:not(:disabled):hover {
    opacity: 0.9;
}

.disclaimer {
    text-align: center;
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 12px;
}

.footer-links {
    display: inline-block;
    margin-left: 8px;
}

.footer-links a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.2s;
}

.footer-links a:hover {
    color: var(--accent-primary);
    text-decoration: underline;
}

.footer-links .divider {
    margin: 0 6px;
    color: var(--text-tertiary);
}

/* ========== 右上角用户菜单 ========== */
.user-menu {
    display: none;
    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;
}

/* 积分显示可点击 */
a.credits-display {
    text-decoration: none;
    color: inherit;
}

a.credits-display:hover {
    opacity: 0.8;
}

/* 侧边栏用户信息可点击 */
a.user-info {
    text-decoration: none;
    color: inherit;
}

a.user-info:hover {
    background-color: var(--bg-hover);
    border-radius: 8px;
}

/* ========== 设置弹窗 ========== */
.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: 400px;
    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;
}

.setting-group {
    margin-bottom: 24px;
}

.setting-group:last-child {
    margin-bottom: 0;
}

.setting-group label {
    display: block;
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.ratio-options,
.size-options {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.ratio-btn,
.size-btn {
    padding: 10px 16px;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.ratio-btn:hover,
.size-btn:hover {
    border-color: var(--border-light);
    color: var(--text-primary);
}

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

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

/* ========== 图片查看器 ========== */
.image-viewer {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.9);
    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);
}

/* ========== 响应式 ========== */
@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;
    }

    .welcome-title,
    .welcome-subtitle {
        font-size: 28px;
    }

    .quick-prompts {
        flex-direction: column;
        align-items: center;
    }

    .prompt-card {
        max-width: 100%;
        width: 100%;
    }

    .input-section {
        padding: 12px 16px 16px;
    }

    .chat-section {
        padding: 16px;
    }
}

/* ========== 滚动条 ========== */
::-webkit-scrollbar {
    width: 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);
}
