/* ========== 暗色/亮色模式全局样式 ========== */

/* 亮色模式（默认） */
:root {
    --bg-primary: #f0fdf4;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-input: #ffffff;
    --text-primary: #111827;
    --text-secondary: #4b5563;
    --text-muted: #9ca3af;
    --border-color: #d1d5db;
    --border-light: #e5e7eb;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
    --hover-bg: #f0fdf4;
    --accent: #10b981;
    --accent-light: rgba(16, 185, 129, 0.1);
}

/* 暗色模式 */
[data-theme="dark"] {
    --bg-primary: #0c1222;
    --bg-secondary: #162032;
    --bg-card: #1a2744;
    --bg-input: #243352;
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border-color: #2d4a6f;
    --border-light: #1e3a5f;
    --shadow: 0 1px 3px rgba(0,0,0,0.4);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.4);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.5);
    --hover-bg: #243352;
    --accent: #34d399;
    --accent-light: rgba(52, 211, 153, 0.15);
}

/* 基础元素 */
body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.7;
    font-size: 15px;
}

/* 卡片 */
.bg-white {
    background-color: var(--bg-card) !important;
    color: var(--text-primary) !important;
    box-shadow: var(--shadow) !important;
    border: 1px solid var(--border-light) !important;
}
.bg-gray-50 {
    background-color: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
}

/* 文字颜色 */
.text-gray-900, .text-gray-800, .text-gray-700 {
    color: var(--text-primary) !important;
}
.text-gray-600, .text-gray-500 {
    color: var(--text-secondary) !important;
}
.text-gray-400, .text-gray-300 {
    color: var(--text-muted) !important;
}

/* 边框 */
.border, .border-b, .border-t, .border-r, .border-l {
    border-color: var(--border-color) !important;
}
.border-gray-200 {
    border-color: var(--border-color) !important;
}
.divide-y > * {
    border-top-color: var(--border-color) !important;
}

/* 输入框 */
input[type="text"], input[type="password"], input[type="email"], input[type="number"],
textarea, select {
    background-color: var(--bg-input) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
    border-radius: 0.5rem !important;
    padding: 0.625rem 1rem !important;
}
input:focus, textarea:focus, select:focus {
    border-color: var(--accent) !important;
    box-shadow: 0 0 0 3px var(--accent-light) !important;
    outline: none !important;
}

/* 底部导航栏 */
.bottom-nav {
    background: var(--bg-secondary) !important;
    border-top-color: var(--border-color) !important;
    backdrop-filter: blur(10px);
}

/* 帖子列表 */
.post-item {
    border-bottom: 1px solid var(--border-light) !important;
}
.post-item:hover {
    background: var(--hover-bg) !important;
}

/* 分页 */
.rounded-lg.text-gray-600 {
    background-color: var(--bg-card) !important;
    color: var(--text-secondary) !important;
}

/* 页脚 */
.bg-gray-800 {
    background-color: var(--bg-secondary) !important;
}

/* 链接 */
a.text-emerald-600, a.text-emerald-500 {
    color: var(--accent) !important;
}
a:hover {
    opacity: 0.85;
}

/* 搜索框 */
input::placeholder {
    color: var(--text-muted) !important;
}

/* 侧边栏（后台） */
.sidebar {
    background: linear-gradient(180deg, #0f172a 0%, #020617 100%) !important;
}

/* 后台内容区 */
.bg-gray-100 {
    background-color: var(--bg-primary) !important;
}

/* 绿色强调色 */
.text-emerald-600, .text-emerald-500 { color: var(--accent) !important; }
.bg-emerald-500, .bg-emerald-600 { background-color: var(--accent) !important; }
.bg-emerald-50 { background-color: var(--accent-light) !important; }

/* 状态颜色保持鲜明 */
.bg-red-500 { background-color: #ef4444 !important; }
.bg-red-100 { background-color: #fee2e2 !important; }
.text-red-600, .text-red-700 { color: #dc2626 !important; }
.bg-green-50 { background-color: #f0fdf4 !important; }
.bg-green-100 { background-color: #dcfce7 !important; }
.text-green-600, .text-green-700 { color: #16a34a !important; }
.bg-yellow-100 { background-color: #fef9c3 !important; }
.text-yellow-700 { color: #a16207 !important; }
.bg-purple-100 { background-color: #f3e8ff !important; }
.text-purple-600 { color: #9333ea !important; }
.bg-blue-100 { background-color: #dbeafe !important; }
.bg-orange-100 { background-color: #ffedd5 !important; }
.bg-amber-100 { background-color: #fef3c7 !important; }
.text-amber-600, .text-amber-700 { color: #d97706 !important; }
.bg-pink-100 { background-color: #fce7f3 !important; }

/* 暗色模式下保持状态颜色 */
[data-theme="dark"] .bg-red-100 { background-color: rgba(239, 68, 68, 0.2) !important; }
[data-theme="dark"] .bg-green-100 { background-color: rgba(34, 197, 94, 0.2) !important; }
[data-theme="dark"] .bg-yellow-100 { background-color: rgba(234, 179, 8, 0.2) !important; }
[data-theme="dark"] .bg-purple-100 { background-color: rgba(168, 85, 247, 0.2) !important; }
[data-theme="dark"] .bg-blue-100 { background-color: rgba(59, 130, 246, 0.2) !important; }
[data-theme="dark"] .bg-orange-100 { background-color: rgba(249, 115, 22, 0.2) !important; }
[data-theme="dark"] .bg-amber-100 { background-color: rgba(245, 158, 11, 0.2) !important; }
[data-theme="dark"] .bg-pink-100 { background-color: rgba(236, 72, 153, 0.2) !important; }
[data-theme="dark"] .bg-green-50 { background-color: rgba(34, 197, 94, 0.15) !important; }
[data-theme="dark"] .bg-red-50 { background-color: rgba(239, 68, 68, 0.15) !important; }

/* ========== 导航和按钮可读性 ========== */

/* 顶部导航链接 */
.header-bg a {
    color: white !important;
    text-decoration: none !important;
}
.header-bg a:hover {
    opacity: 0.9;
}

/* 顶部导航背景 - 亮色绿色，暗色深色 */
.header-bg {
    background: #047857 !important;
    background-image: none !important;
}
[data-theme="dark"] .header-bg {
    background: #0f172a !important;
    background-image: none !important;
}

/* 顶部导航链接 - 加粗加阴影增强可读性 */
.header-bg a {
    color: white !important;
    text-decoration: none !important;
    font-weight: 500 !important;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
}
.header-bg a:hover {
    opacity: 0.9;
}

/* 顶部导航标题 */
.header-bg .text-xl.font-bold {
    font-size: 1.25rem !important;
    font-weight: 700 !important;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}
[data-theme="dark"] .header-bg {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f172a 100%) !important;
}

/* 底部导航栏 - 统一样式 */
.bottom-nav {
    background: var(--bg-secondary) !important;
    border-top-color: var(--border-color) !important;
    backdrop-filter: blur(10px);
    padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav .nav-item {
    color: var(--text-secondary) !important;
    padding: 0.5rem 0 !important;
}
.bottom-nav .nav-item svg {
    width: 1.25rem !important;
    height: 1.25rem !important;
}
.bottom-nav .nav-item span {
    font-size: 0.65rem !important;
    margin-top: 0.15rem !important;
}
.bottom-nav .nav-item.text-emerald-600 {
    color: var(--accent) !important;
}

/* 退出按钮样式 */
.header-bg .btn-logout,
.header-bg a[href="logout.php"] {
    background: rgba(255,255,255,0.15) !important;
    padding: 0.375rem 0.75rem !important;
    border-radius: 0.5rem !important;
    font-size: 0.875rem !important;
    transition: all 0.2s !important;
    backdrop-filter: blur(4px);
}
.header-bg a[href="logout.php"]:hover {
    background: rgba(255,255,255,0.25) !important;
}

/* 登录/注册按钮 */
.header-bg a[href="login.php"] {
    background: rgba(255,255,255,0.15) !important;
    padding: 0.375rem 0.75rem !important;
    border-radius: 0.5rem !important;
    font-size: 0.875rem !important;
    transition: all 0.2s !important;
}
.header-bg a[href="login.php"]:hover {
    background: rgba(255,255,255,0.25) !important;
}
.header-bg a[href="register.php"] {
    background: white !important;
    color: #059669 !important;
    padding: 0.375rem 1rem !important;
    border-radius: 0.5rem !important;
    font-weight: 500 !important;
    font-size: 0.875rem !important;
    transition: all 0.2s !important;
}
.header-bg a[href="register.php"]:hover {
    background: #f0fdf4 !important;
}

/* 发帖按钮 */
.header-bg a[href="new.php"] {
    background: white !important;
    color: #059669 !important;
    padding: 0.375rem 1rem !important;
    border-radius: 0.5rem !important;
    font-weight: 500 !important;
    transition: all 0.2s !important;
}

/* 用户名区域 */
.header-bg .flex.items-center.gap-2 {
    background: rgba(255,255,255,0.1) !important;
    padding: 0.25rem 0.75rem !important;
    border-radius: 0.5rem !important;
}

/* 底部导航文字 */
.bottom-nav .nav-item span {
    font-size: 0.7rem !important;
}
.bottom-nav svg {
    width: 1.25rem !important;
    height: 1.25rem !important;
}

/* ========== 头像裁剪弹窗 ========== */
.crop-modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.7);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}
.crop-container {
    background: var(--bg-card);
    border-radius: 1rem;
    padding: 1.5rem;
    max-width: 500px;
    width: 90%;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
}
.crop-container img {
    max-width: 100%;
    display: block;
}
.crop-btn-group {
    display: flex;
    gap: 0.75rem;
    margin-top: 1rem;
    justify-content: flex-end;
}
.crop-btn {
    padding: 0.5rem 1.25rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}
.crop-btn-primary {
    background: #10b981;
    color: white;
}
.crop-btn-primary:hover {
    background: #059669;
}
.crop-btn-cancel {
    background: var(--bg-input);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}
.crop-btn-cancel:hover {
    background: var(--hover-bg);
}

/* 暗色模式 */
[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: #1e293b;
    --bg-input: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border-color: #334155;
    --border-light: #1e293b;
    --shadow: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.3);
    --hover-bg: #334155;
}

/* 基础元素 */
body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
}

/* 卡片 */
.bg-white, .bg-gray-50 {
    background-color: var(--bg-card) !important;
    color: var(--text-primary) !important;
}

/* 文字颜色 */
.text-gray-800, .text-gray-700, .text-gray-900 {
    color: var(--text-primary) !important;
}
.text-gray-600, .text-gray-500 {
    color: var(--text-secondary) !important;
}
.text-gray-400, .text-gray-300 {
    color: var(--text-muted) !important;
}

/* 边框 */
.border, .border-b, .border-t, .border-r {
    border-color: var(--border-color) !important;
}
.border-gray-200 {
    border-color: var(--border-color) !important;
}
.divide-y > * {
    border-color: var(--border-color) !important;
}

/* 输入框 */
input[type="text"], input[type="password"], input[type="email"], input[type="number"],
textarea, select {
    background-color: var(--bg-input) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

/* 底部导航栏 */
.bottom-nav {
    background: var(--bg-secondary) !important;
    border-top-color: var(--border-color) !important;
}

/* 帖子列表悬停 */
.post-item:hover {
    background: var(--hover-bg) !important;
}

/* 分页按钮 */
.bg-white.rounded-lg.text-gray-600 {
    background-color: var(--bg-card) !important;
    color: var(--text-secondary) !important;
}

/* 页脚 */
.bg-gray-800 {
    background-color: var(--bg-secondary) !important;
}

/* 搜索框 */
input::placeholder {
    color: var(--text-muted) !important;
}

/* 侧边栏（后台） */
.sidebar {
    background: linear-gradient(180deg, #0f172a 0%, #020617 100%) !important;
}

/* 暗色模式下的绿色强调色保持不变 */
.text-emerald-600, .text-emerald-500 { color: #10b981 !important; }
.bg-emerald-500, .bg-emerald-600 { background-color: #10b981 !important; }
.bg-emerald-50 { background-color: rgba(16, 185, 129, 0.1) !important; }

/* 暗色模式下保持徽章颜色 */
.bg-red-500, .bg-red-100, .bg-green-50, .bg-green-100,
.bg-yellow-100, .bg-purple-100, .bg-blue-100, .bg-orange-100,
.bg-amber-100, .bg-pink-100 {
    opacity: 1 !important;
}

/* ========== Quill 编辑器内容样式 ========== */
.post-content .ql-size-small, .ql-size-small { font-size: 0.75em; }
.post-content .ql-size-large, .ql-size-large { font-size: 1.5em; }
.post-content .ql-size-huge, .ql-size-huge { font-size: 2em; }
.post-content a, a.post-link { color: #10b981; text-decoration: underline; }
.post-content a:hover { color: #059669; }
.post-content img { max-width: 100%; height: auto; border-radius: 0.5rem; }
.post-content ul, .post-content ol { padding-left: 1.5rem; margin: 0.5rem 0; }
.post-content blockquote { border-left: 4px solid #10b981; padding-left: 1rem; margin: 0.5rem 0; color: #6b7280; }
.post-content code { background: #f3f4f6; padding: 0.25rem 0.5rem; border-radius: 0.25rem; font-family: monospace; }
.post-content pre { background: #f3f4f6; padding: 1rem; border-radius: 0.5rem; overflow-x: auto; }
.post-content p { margin: 0.5rem 0; }
.post-content h1 { font-size: 1.5em; font-weight: 700; margin: 0.5rem 0; }
.post-content h2 { font-size: 1.3em; font-weight: 700; margin: 0.5rem 0; }
.post-content h3 { font-size: 1.1em; font-weight: 700; margin: 0.5rem 0; }
[data-theme="dark"] .post-content code { background: #334155; }
[data-theme="dark"] .post-content pre { background: #334155; }

/* ========== 手机端优化 ========== */
@media (max-width: 768px) {
    /* 头部 */
    .header-bg .text-lg { font-size: 1rem !important; }
    .header-bg .text-xl { font-size: 1rem !important; }
    
    /* 内容区 */
    main { padding: 0.75rem !important; }
    
    /* 卡片 */
    .bg-white { border-radius: 0.75rem !important; }
    
    /* 底部导航 */
    .bottom-nav { height: auto !important; }
    .bottom-nav .max-w-6xl { padding: 0 !important; }
}
