/* 千灵写作网站主样式文件 */

/* CSS 变量定义 */
:root {
    /* 深色主题（默认） */
    --primary-gradient: linear-gradient(135deg, #1e3c72 0%, #2a5298 50%, #6a5acd 100%);
    --secondary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --accent-color: #ffd700;
    --accent-hover: #ffed4e;

    /* 文字颜色 */
    --text-primary: #ffffff;
    --text-secondary: #e2e8f0;
    --text-muted: #a0aec0;
    --text-dark: #2d3748;

    /* 背景色 */
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: rgba(30, 41, 59, 0.8);
    --bg-overlay: rgba(0, 0, 0, 0.5);

    /* 边框和阴影 */
    --border-color: rgba(255, 255, 255, 0.1);
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    --shadow-light: 0 2px 8px rgba(0, 0, 0, 0.1);

    /* 尺寸 */
    --sidebar-width: 280px;
    --sidebar-collapsed-width: 80px;
    --header-height: 70px;
    --border-radius: 12px;
    --border-radius-sm: 8px;
    --border-radius-lg: 16px;

    /* 动画 */
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
}

/* 浅色主题 */
[data-theme="light"] {
    /* 主题色彩 */
    --primary-gradient: linear-gradient(135deg, #4facfe 0%, #00f2fe 50%, #3b82f6 100%);
    --secondary-gradient: linear-gradient(135deg, #60a5fa 0%, #3b82f6 100%);
    --accent-color: #f59e0b;
    --accent-hover: #d97706;

    /* 文字颜色 */
    --text-primary: #1f2937;
    --text-secondary: #4b5563;
    --text-muted: #6b7280;
    --text-dark: #111827;

    /* 背景色 */
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-card: rgba(255, 255, 255, 0.9);
    --bg-overlay: rgba(0, 0, 0, 0.3);

    /* 边框和阴影 */
    --border-color: rgba(0, 0, 0, 0.1);
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    --shadow-light: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* 浅色主题下的首页背景 */
[data-theme="light"] .home-page {
    background: linear-gradient(135deg,
    #a8edea 0%,
    #fed6e3 25%,
    #d299c2 50%,
    #fef9d7 75%,
    #89f7fe 100%);
}

[data-theme="light"] .home-page::before {
    background: radial-gradient(circle at 20% 80%, rgba(168, 237, 234, 0.4) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(254, 214, 227, 0.4) 0%, transparent 50%),
    radial-gradient(circle at 40% 40%, rgba(137, 247, 254, 0.3) 0%, transparent 50%);
}

/* 浅色主题下的侧边栏优化 */
[data-theme="light"] .sidebar-header {
    background: rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .sidebar-header::before {
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.1) 0%, rgba(0, 0, 0, 0.05) 100%);
}

[data-theme="light"] .nav-link:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .nav-link.active {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.2), rgba(245, 158, 11, 0.1));
    border: 1px solid rgba(245, 158, 11, 0.3);
    box-shadow: 0 4px 15px rgba(245, 158, 11, 0.2);
}

/* 全局重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    font-family: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

/* 应用容器 */
.app-container {
    display: flex;
    min-height: 100vh;
    position: relative;
}

/* 侧边导航栏 */
.sidebar {
    width: var(--sidebar-width);
    background: var(--primary-gradient);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: transform var(--transition-normal);
    box-shadow: var(--shadow-xl);
    backdrop-filter: blur(20px);
    border-right: 1px solid var(--border-color);
}

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

.sidebar-header {
    padding: 1.5rem 1rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: var(--header-height);
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    position: relative;
}

.sidebar-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.05) 100%);
    pointer-events: none;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    position: relative;
    z-index: 1;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    position: relative;
    z-index: 1;
    padding: 0.5rem;
    border-radius: var(--border-radius-sm);
    transition: all var(--transition-fast);
}

.logo-container:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-1px);
}

.logo {
    width: 40px;
    height: 40px;
    border-radius: var(--border-radius-sm);
}

.logo-text {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    transition: opacity var(--transition-fast);
}

.sidebar.collapsed .logo-text {
    opacity: 0;
    pointer-events: none;
}

/* 收起状态下的侧边栏头部优化 */
.sidebar.collapsed .sidebar-header {
    padding: 0.75rem 0;
    flex-direction: column;
    gap: 0.375rem;
    justify-content: flex-start;
    align-items: center;
    min-height: auto;
}

.sidebar.collapsed .logo-container {
    padding: 0;
    gap: 0;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 40px;
    margin: 0;
    display: flex;
    position: relative;
}

.sidebar.collapsed .logo-placeholder-small {
    width: 32px;
    height: 32px;
    font-size: 0.875rem;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
}

.sidebar.collapsed .header-controls {
    gap: 0.25rem;
    flex-direction: row;
    width: 100%;
    justify-content: center;
    align-items: center;
}

.sidebar.collapsed .theme-toggle,
.sidebar.collapsed .sidebar-toggle {
    padding: 0.25rem;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
}

.sidebar.collapsed .theme-icon {
    font-size: 0.75rem;
}

.sidebar.collapsed .hamburger {
    width: 14px;
    height: 1.5px;
}

.sidebar.collapsed .hamburger::before,
.sidebar.collapsed .hamburger::after {
    height: 1.5px;
    top: -4px;
}

.sidebar.collapsed .hamburger::after {
    top: 4px;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--border-radius-sm);
    transition: background-color var(--transition-fast);
}

.sidebar-toggle:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.toggle-icon {
    width: 20px;
    height: 20px;
    filter: brightness(0) invert(1);
    transition: transform var(--transition-fast);
}

.sidebar-toggle:hover .toggle-icon {
    transform: scale(1.1);
}

/* 默认状态：显示收起图标（左箭头），隐藏展开图标（右箭头） */
.toggle-icon-collapse,
.toggle-fallback-collapse {
    display: inline-block;
}

.toggle-icon-expand,
.toggle-fallback-expand {
    display: none;
}

/* 收起状态：隐藏收起图标，显示展开图标 */
.sidebar.collapsed .toggle-icon-collapse,
.sidebar.collapsed .toggle-fallback-collapse {
    display: none;
}

.sidebar.collapsed .toggle-icon-expand,
.sidebar.collapsed .toggle-fallback-expand {
    display: inline-block;
}

/* 表情图标回退样式 */
.toggle-fallback {
    width: 20px;
    height: 20px;
    background: none;
    position: relative;
    font-size: 16px;
    line-height: 20px;
    text-align: center;
    color: var(--text-primary);
    transition: transform var(--transition-fast);
}

.sidebar-toggle:hover .toggle-fallback {
    transform: scale(1.1);
}

/* 保留原来的 hamburger 类以防兼容性问题 */
.hamburger {
    display: block;
    width: 20px;
    height: 20px;
    background: none;
    position: relative;
    font-size: 16px;
    line-height: 20px;
    text-align: center;
    color: var(--text-primary);
}

/* 原来的 hamburger 线条样式已被表情图标替代 */
/*
.hamburger::before,
.hamburger::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 2px;
    background: currentColor;
    transition: transform var(--transition-fast);
}

.hamburger::before {
    top: -6px;
}

.hamburger::after {
    top: 6px;
}
*/

/* 导航菜单 */
.sidebar-content {
    flex: 1;
    padding: 1rem 0;
    overflow-y: auto;
}

.nav-menu {
    list-style: none;
}

.nav-item {
    margin: 0.25rem 0;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.875rem 1.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all var(--transition-fast);
    position: relative;
    border-radius: var(--border-radius-sm);
    margin: 0.25rem 0.75rem;
    overflow: hidden;
}

.nav-link::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transition: left 0.5s ease;
}

.nav-link:hover::before {
    left: 100%;
}

.nav-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    transform: translateX(4px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.nav-link.active {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.2), rgba(255, 215, 0, 0.1));
    color: var(--accent-color);
    font-weight: 500;
    border: 1px solid rgba(255, 215, 0, 0.3);
    box-shadow: 0 4px 15px rgba(255, 215, 0, 0.2);
}

.nav-link.active::after {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--accent-color);
    border-radius: 0 2px 2px 0;
}

.nav-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    object-fit: contain;
    filter: brightness(0) invert(1);
    transition: all var(--transition-fast);
}

.nav-icon-fallback {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* 浅色主题下的图标滤镜 */
[data-theme="light"] .nav-icon {
    filter: brightness(0) invert(0.3);
}

/* 活跃状态下的图标 */
.nav-link.active .nav-icon {
    filter: brightness(0) saturate(100%) invert(85%) sepia(85%) saturate(2000%) hue-rotate(15deg);
}

[data-theme="light"] .nav-link.active .nav-icon {
    filter: brightness(0) saturate(100%) invert(60%) sepia(85%) saturate(2000%) hue-rotate(15deg);
}

/* 悬停状态下的图标 */
.nav-link:hover .nav-icon {
    transform: scale(1.1);
    filter: brightness(0) invert(1);
}

[data-theme="light"] .nav-link:hover .nav-icon {
    filter: brightness(0) invert(0.1);
}

.nav-text {
    transition: opacity var(--transition-fast);
}

.sidebar.collapsed .nav-text {
    opacity: 0;
    pointer-events: none;
}

/* 收起状态下的导航链接优化 */
.sidebar.collapsed .nav-item {
    margin: 0.125rem 0;
}

.sidebar.collapsed .nav-link {
    padding: 0;
    margin: 0.125rem 0.75rem;
    justify-content: center;
    align-items: center;
    gap: 0;
    height: 40px;
    width: calc(100% - 1.5rem);
    border-radius: var(--border-radius-sm);
    display: flex;
    position: relative;
}

.sidebar.collapsed .nav-link:hover {
    transform: scale(1.05);
    background-color: rgba(255, 255, 255, 0.15);
}

.sidebar.collapsed .nav-icon {
    margin: 0 auto;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    display: block;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.sidebar.collapsed .nav-icon-fallback {
    width: 18px;
    height: 18px;
    font-size: 18px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.sidebar.collapsed .nav-link.active::after {
    display: none;
}

.sidebar.collapsed .nav-link.active {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.25), rgba(255, 215, 0, 0.15));
    border: 1px solid rgba(255, 215, 0, 0.3);
    box-shadow: 0 2px 8px rgba(255, 215, 0, 0.2);
}

/* 收起状态下的侧边栏内容区域优化 */
.sidebar.collapsed .sidebar-content {
    padding: 0.75rem 0;
}

/* 收起状态下的版本信息优化 */
.sidebar.collapsed .sidebar-footer {
    padding: 0.75rem 0.5rem;
}

.sidebar.collapsed .version-text {
    font-size: 0.7rem;
    opacity: 0.7;
}

/* 侧边栏底部 */
.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
}

.version-info {
    text-align: center;
}

.version-text {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* 主内容区域 */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: margin-left var(--transition-normal);
    background: var(--bg-primary);
    position: relative;
}

/* 首页特殊背景 */
.home-page {
    background: linear-gradient(135deg,
    #667eea 0%,
    #764ba2 25%,
    #f093fb 50%,
    #f5576c 75%,
    #4facfe 100%);
    background-size: 400% 400%;
    animation: gradientShift 15s ease infinite;
    min-height: 100vh;
    position: relative;
}

.home-page::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at 20% 80%, rgba(120, 119, 198, 0.3) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(255, 119, 198, 0.3) 0%, transparent 50%),
    radial-gradient(circle at 40% 40%, rgba(120, 219, 255, 0.2) 0%, transparent 50%);
    pointer-events: none;
}

.home-page .page-container {
    position: relative;
    z-index: 1;
}

.sidebar.collapsed + .main-content {
    margin-left: var(--sidebar-collapsed-width);
}

/* 页面容器 */
.page-container {
    padding: 2rem;
    max-width: 1200px;
    margin: 0 auto;
    /* 防止内容挤压的关键样式 */
    word-wrap: break-word;
    overflow-wrap: break-word;
    min-width: 0;
    box-sizing: border-box;
    width: 100%;
}

/* 首页页面容器特殊样式 */
.home-page .page-container {
    padding: 0;
    max-width: none;
    margin: 0;
}

/* 区域标题样式 */
.section-title {
    font-size: 2.5rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 1rem;
    background: linear-gradient(45deg, var(--text-primary), var(--accent-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.section-subtitle {
    font-size: 1.125rem;
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 3rem;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
    line-height: 1.6;
}

/* 特性高亮区域 */
.feature-highlights {
    padding: 4rem 2rem;
    position: relative;
}

.feature-highlights::before {
    content: '';
    position: absolute;
    top: 2rem;
    left: 2rem;
    right: 2rem;
    bottom: 2rem;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    border-radius: var(--border-radius);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.feature-highlights .section-header {
    position: relative;
    z-index: 1;
    margin-bottom: 3rem;
}

/* 浅色主题下的特性高亮区域 */
[data-theme="light"] .feature-highlights::before {
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
}

/* 响应式设计 */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

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

    .main-content {
        margin-left: 0;
    }

    .page-container {
        padding: 1rem;
    }
}

/* 滚动条样式 */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

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

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* 选择文本样式 */
::selection {
    background: var(--accent-color);
    color: var(--text-dark);
}

/* 主题切换按钮 */
.theme-toggle {
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--border-radius-sm);
    transition: all var(--transition-fast);
    position: relative;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.theme-toggle:hover {
    background-color: rgba(255, 255, 255, 0.1);
    transform: scale(1.1);
}

.theme-toggle:active {
    transform: scale(0.95);
}

/* 主题切换动画 */
.theme-toggle .theme-icon {
    transition: all var(--transition-normal);
    transform-origin: center;
}

.theme-toggle .theme-icon.rotating {
    transform: rotate(360deg);
}

/* 浅色主题下的主题切换按钮 */
[data-theme="light"] .theme-toggle:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

/* 主题切换提示 */
.theme-toggle-tooltip {
    position: absolute;
    bottom: -35px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-secondary);
    color: var(--text-primary);
    padding: 0.25rem 0.5rem;
    border-radius: var(--border-radius-sm);
    font-size: 0.75rem;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-fast);
    z-index: 1000;
    box-shadow: var(--shadow-md);
}

.theme-toggle:hover .theme-toggle-tooltip {
    opacity: 1;
    visibility: visible;
}
