/* ===== Teafo 主题系统 ===== */
:root {
    --bg: #f7fcff;
    --bg-card: #ffffff;
    --bg-hover: #f0f7ff;
    --bg-topbar: #1677ff;
    --text: #1a1a1a;
    --text-secondary: #666;
    --text-muted: #999;
    --border: #e0e0e0;
    --border-light: #eee;
    --primary: #1677ff;
    --primary-hover: #0066dd;
    --danger: #e65100;
    --success: #00C851;
    --input-bg: #fff;
    --input-border: #ddd;
    --code-bg: #f5f5f5;
    --shadow: 0 2px 8px rgba(0,0,0,0.06);
}

[data-theme="dark"] {
    --bg: #0f1115;
    --bg-card: #1a1d24;
    --bg-hover: #252830;
    --bg-topbar: #1a1d24;
    --text: #e4e6eb;
    --text-secondary: #a0a3ab;
    --text-muted: #6b6f76;
    --border: #2d3139;
    --border-light: #252830;
    --primary: #4d9fff;
    --primary-hover: #66b0ff;
    --danger: #ff6b4a;
    --success: #4ade80;
    --input-bg: #252830;
    --input-border: #3d4148;
    --code-bg: #252830;
    --shadow: 0 2px 8px rgba(0,0,0,0.3);
}

/* 基础覆盖 */
[data-theme="dark"] body {
    background: var(--bg) !important;
    color: var(--text) !important;
}

[data-theme="dark"] .box,
[data-theme="dark"] .card,
[data-theme="dark"] .user-bar,
[data-theme="dark"] .sign-tip {
    background: var(--bg-card) !important;
    color: var(--text) !important;
    border-color: var(--border) !important;
}

[data-theme="dark"] .box h3,
[data-theme="dark"] .card h3 {
    color: var(--text) !important;
}

[data-theme="dark"] .item {
    border-bottom-color: var(--border) !important;
}

[data-theme="dark"] .meta,
[data-theme="dark"] .text-muted,
[data-theme="dark"] .text-secondary {
    color: var(--text-muted) !important;
}

[data-theme="dark"] input,
[data-theme="dark"] textarea,
[data-theme="dark"] select {
    background: var(--input-bg) !important;
    color: var(--text) !important;
    border-color: var(--input-border) !important;
}

[data-theme="dark"] table {
    color: var(--text) !important;
}

[data-theme="dark"] table th {
    background: var(--bg-hover) !important;
    color: var(--text-secondary) !important;
}

[data-theme="dark"] table td,
[data-theme="dark"] table th {
    border-bottom-color: var(--border) !important;
}

[data-theme="dark"] pre,
[data-theme="dark"] code {
    background: var(--code-bg) !important;
    color: var(--text) !important;
}

[data-theme="dark"] .alert-success {
    background: #14532d !important;
    color: #86efac !important;
    border-color: #166534 !important;
}

[data-theme="dark"] .alert-error {
    background: #7f1d1d !important;
    color: #fca5a5 !important;
    border-color: #991b1b !important;
}

[data-theme="dark"] .alert-info {
    background: #1e3a5f !important;
    color: #93c5fd !important;
    border-color: #1e40af !important;
}

[data-theme="dark"] .badge {
    background: #1e3a5f !important;
    color: #64b5f6 !important;
}

/* 内联样式覆盖 - 背景色 */
[data-theme="dark"] [style*="background:#fff"],
[data-theme="dark"] [style*="background: #fff"],
[data-theme="dark"] [style*="background:#ffffff"],
[data-theme="dark"] [style*="background: #ffffff"],
[data-theme="dark"] [style*="background:white"],
[data-theme="dark"] [style*="background: white"] {
    background: var(--bg-card) !important;
}

[data-theme="dark"] [style*="background:#f7fcff"],
[data-theme="dark"] [style*="background: #f7fcff"] {
    background: var(--bg) !important;
}

[data-theme="dark"] [style*="background:#f5f5f5"],
[data-theme="dark"] [style*="background: #f5f5f5"],
[data-theme="dark"] [style*="background:#f0f7ff"],
[data-theme="dark"] [style*="background: #f0f7ff"] {
    background: var(--bg-hover) !important;
}

/* 内联样式覆盖 - 文字颜色 */
[data-theme="dark"] [style*="color:#333"],
[data-theme="dark"] [style*="color: #333"],
[data-theme="dark"] [style*="color:#333333"],
[data-theme="dark"] [style*="color: #333333"] {
    color: var(--text) !important;
}

[data-theme="dark"] [style*="color:#666"],
[data-theme="dark"] [style*="color: #666"],
[data-theme="dark"] [style*="color:#666666"],
[data-theme="dark"] [style*="color: #666666"] {
    color: var(--text-secondary) !important;
}

[data-theme="dark"] [style*="color:#999"],
[data-theme="dark"] [style*="color: #999"],
[data-theme="dark"] [style*="color:#999999"],
[data-theme="dark"] [style*="color: #999999"] {
    color: var(--text-muted) !important;
}

/* 内联样式覆盖 - 边框 */
[data-theme="dark"] [style*="border-bottom:1px solid #eee"],
[data-theme="dark"] [style*="border-bottom: 1px solid #eee"],
[data-theme="dark"] [style*="border:1px solid #eee"],
[data-theme="dark"] [style*="border: 1px solid #eee"],
[data-theme="dark"] [style*="border-bottom:1px solid #ddd"],
[data-theme="dark"] [style*="border:1px solid #ddd"] {
    border-color: var(--border) !important;
}

/* 主题切换浮动按钮 */
.theme-float-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 10px 16px;
    border-radius: 20px;
    background: var(--primary);
    color: #fff;
    border: 2px solid rgba(255,255,255,0.3);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    z-index: 9999;
    transition: transform 0.2s, opacity 0.2s;
}

.theme-float-btn:hover {
    transform: scale(1.05);
}

.theme-toggle-btn {
    background: rgba(255,255,255,0.2);
    color: #fff;
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
}

@media (max-width: 768px) {
    .theme-float-btn {
        bottom: 16px;
        right: 16px;
        padding: 8px 14px;
        font-size: 13px;
    }
}

/* index.php 在线用户区域 */
[data-theme="dark"] .online-box {
    background: var(--bg-card) !important;
    border-color: var(--border) !important;
}
[data-theme="dark"] .online-user {
    background: var(--bg-hover) !important;
}
[data-theme="dark"] .online-user a {
    color: var(--text) !important;
}
[data-theme="dark"] .new-online-user {
    background: #3d2e1a !important;
}
[data-theme="dark"] .new-online-user a {
    color: #ffb74d !important;
}
[data-theme="dark"] [style*="color:#f57c00"],
[data-theme="dark"] [style*="color: #f57c00"] {
    color: #ffb74d !important;
}
[data-theme="dark"] [style*="color:#e65100"],
[data-theme="dark"] [style*="color: #e65100"] {
    color: #ff8a65 !important;
}
[data-theme="dark"] [style*="color:#555"],
[data-theme="dark"] [style*="color: #555"] {
    color: var(--text-secondary) !important;
}
[data-theme="dark"] [style*="background:#e8f5e9"],
[data-theme="dark"] [style*="background: #e8f5e9"],
[data-theme="dark"] [style*="background:#d1f7d2"],
[data-theme="dark"] [style*="background: #d1f7d2"],
[data-theme="dark"] [style*="background:#ffe0b2"],
[data-theme="dark"] [style*="background: #ffe0b2"] {
    background: var(--bg-hover) !important;
}


/* ===== 通用移动端增强 ===== */
@media (max-width: 768px) {
    .topbar {
        padding: 8px 12px !important;
        gap: 8px !important;
        flex-wrap: wrap !important;
    }
    .topbar .nav-links {
        display: none !important;
    }
    .topbar .nav-right {
        display: flex !important;
        gap: 4px !important;
    }
    .topbar .btn, .topbar .nav-links a {
        padding: 5px 8px !important;
        font-size: 13px !important;
    }
    .container {
        padding: 0 8px !important;
        margin: 10px auto !important;
    }
    .box, .card {
        padding: 12px !important;
        border-radius: 8px !important;
    }
    .btn {
        padding: 10px 14px !important;
        font-size: 14px !important;
    }
    input, textarea, select {
        padding: 10px 12px !important;
        font-size: 16px !important; /* 防止iOS缩放 */
    }
    table {
        font-size: 13px !important;
    }
    table th, table td {
        padding: 8px 6px !important;
    }
    .grid-2, .grid-3 {
        grid-template-columns: 1fr !important;
    }
    /* 表格横向滚动 */
    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .table-wrapper table {
        min-width: 500px;
    }
    /* 帖子内容 */
    .thread-item, .m-thread {
        padding: 10px 0 !important;
    }
    /* 头像 */
    .avatar {
        width: 36px !important;
        height: 36px !important;
    }
    .avatar-lg {
        width: 56px !important;
        height: 56px !important;
    }
    /* 分页 */
    .pagination {
        gap: 4px !important;
    }
    .pagination a, .pagination span {
        padding: 6px 10px !important;
        font-size: 13px !important;
    }
}

@media (max-width: 480px) {
    .topbar .logo img {
        height: 24px !important;
    }
    .box, .card {
        padding: 10px !important;
    }
    .btn {
        width: 100% !important;
        text-align: center !important;
        margin: 4px 0 !important;
    }
    .btn-sm {
        width: auto !important;
    }
    .topbar .btn {
        width: auto !important;
    }
    h1 { font-size: 20px !important; }
    h2 { font-size: 18px !important; }
    h3 { font-size: 16px !important; }
}
