/* ======================================================================
 *  主题切换按钮 + 深色模式变量覆盖（theme-toggle.css）
 *  与 layouts/app.blade.php + layouts/auth.blade.php 配合
 *  持久化由 theme-toggle.js 处理（localStorage.theme）
 * ====================================================================== */

/* ===== 按钮（fixed 右下角，所有页面统一位置） ===== */
.theme-toggle {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 9999;
    width: 40px;
    height: 40px;
    padding: 0;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: var(--c-bg-card, #fff);
    border: 1px solid var(--c-border, #eef1f6);
    color: #4b5563;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(16, 24, 40, 0.08);
    transition: all 0.3s ease;
    overflow: hidden;
}
.theme-toggle:hover {
    color: #0369a1;
    background: rgba(248, 250, 252, 0.95);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(16, 24, 40, 0.12);
}
.theme-toggle:active { transform: translateY(0); }

/* ===== 内联于导航栏的主题按钮（参考圆角图标按钮样式） ===== */
.theme-toggle.nav-theme-btn,
.nav-actions .theme-toggle {
    position: static;
    right: auto;
    bottom: auto;
    z-index: auto;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--c-bg-soft);
    border: 1px solid var(--c-border);
    color: var(--c-text-sub);
    box-shadow: none;
    flex-shrink: 0;
}
.theme-toggle.nav-theme-btn:hover,
.nav-actions .theme-toggle:hover {
    background: var(--c-primary-soft);
    border-color: var(--c-primary);
    color: var(--c-primary);
    transform: scale(1.08);
    box-shadow: none;
}
.theme-toggle.nav-theme-btn:active { transform: scale(0.98); }

/* 图标切换：默认显示月亮（点击切到 dark），dark 模式显示太阳 */
.theme-toggle-icon {
    grid-area: 1 / 1;
    transition: opacity 0.3s ease, transform 0.3s ease;
}
.theme-toggle-icon--sun {
    opacity: 0;
    transform: rotate(-90deg) scale(0.5);
}
/* light 模式：显示月亮 */
:root:not([data-theme="dark"]) .theme-toggle-icon--moon { opacity: 1; transform: rotate(0) scale(1); }
:root:not([data-theme="dark"]) .theme-toggle-icon--sun   { opacity: 0; transform: rotate(90deg) scale(0.5); }
/* dark 模式：显示太阳 */
:root[data-theme="dark"] .theme-toggle-icon--moon { opacity: 0; transform: rotate(-90deg) scale(0.5); }
:root[data-theme="dark"] .theme-toggle-icon--sun  { opacity: 1; transform: rotate(0) scale(1); color: #fbbf24; }

/* auth 页（深色背景）按钮配色微调 */
body:not([class*="home"]) .theme-toggle,
.auth-wrap ~ .theme-toggle {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.10);
    color: #9ca3af;
    backdrop-filter: blur(12px);
}
body:not([class*="home"]) .theme-toggle:hover {
    color: #60a5fa;
    background: rgba(59, 130, 246, 0.10);
}

/* ======================================================================
 *  深色模式变量覆盖
 *  通过 [data-theme="dark"] 重定义 home.css :root 里的变量
 *  所有用 var(--c-xxx) 的元素会自动切换
 * ====================================================================== */
:root[data-theme="dark"] {
    --c-bg: #0b1221;
    --c-bg-soft: #131c31;
    --c-bg-card: #131c31;
    --c-surface: #131c31;
    --c-surface-soft: rgba(255, 255, 255, 0.04);
    --c-surface-2: #0b1221;
    --c-text: #e5e7eb;
    --c-text-sub: #9ca3af;
    --c-text-muted: #6b7280;
    --c-primary: #3b82f6;
    --c-primary-dark: #2563eb;
    --c-primary-soft: rgba(59, 130, 246, 0.12);
    --c-border: rgba(255, 255, 255, 0.08);
    --c-accent-cyan: #06b6d4;
    --c-accent-purple: #8b5cf6;
    --c-accent-pink: #ec4899;
    --c-accent-green: #10b981;
    --c-accent-orange: #f59e0b;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.30);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.40);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.50);
    --shadow-hover: 0 18px 50px rgba(59, 130, 246, 0.20);
    color-scheme: dark;
}

/* ===== dark 模式：硬编码白色背景的元素强制覆盖 ===== */
:root[data-theme="dark"] body {
    background: var(--c-bg);
    color: var(--c-text);
}

/* sticky header 用了 rgba(255,255,255,0.85)，dark 下要变深 */
:root[data-theme="dark"] .header {
    background: rgba(11, 18, 33, 0.85);
    border-bottom-color: var(--c-border);
}

/* 主站顶部导航（.nav-header）硬编码白色背景，dark 下变深 */
:root[data-theme="dark"] .nav-header {
    background: rgba(11, 18, 33, 0.92);
    border-bottom-color: var(--c-border);
}

/* ===== 首页 hero 区深色适配（原本全用浅色硬编码） ===== */
:root[data-theme="dark"] .hero {
    background:
        radial-gradient(1100px 520px at 18% -8%, rgba(59, 130, 246, 0.10) 0%, transparent 60%),
        radial-gradient(900px 480px at 88% 6%, rgba(6, 182, 212, 0.09) 0%, transparent 55%),
        linear-gradient(180deg, #0b1221 0%, #0e1628 100%);
}
:root[data-theme="dark"] .blob-1 { background: rgba(59, 130, 246, 0.22); }
:root[data-theme="dark"] .blob-2 { background: rgba(6, 182, 212, 0.20); }
:root[data-theme="dark"] .blob-3 { background: rgba(139, 92, 246, 0.20); }
/* h1 渐文字原本用深色 #0a1a3a，深色背景上不可见，改为浅色渐变 */
:root[data-theme="dark"] .hero h1 {
    background: linear-gradient(120deg, #f1f5f9 0%, #cbd5e1 42%, #3b82f6 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
:root[data-theme="dark"] .hero h1 .accent {
    background: linear-gradient(120deg, #3b82f6 0%, #06b6d4 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
:root[data-theme="dark"] .hero-badge { background: rgba(19, 28, 49, 0.7); }

/* ===== 分类落地页深色适配（cat-hero / 子分类卡片） ===== */
:root[data-theme="dark"] .cat-hero {
    background: var(--c-bg-card);
    border-color: var(--c-border);
}
:root[data-theme="dark"] .cat-hero-bg {
    background:
        radial-gradient(ellipse at 20% 0%, color-mix(in srgb, var(--cat-color, var(--c-primary)) 24%, transparent) 0%, transparent 55%),
        radial-gradient(ellipse at 100% 100%, color-mix(in srgb, var(--c-accent-cyan) 14%, transparent) 0%, transparent 60%);
}
:root[data-theme="dark"] .cat-hero-info h1 { color: var(--c-text); }
:root[data-theme="dark"] .cat-hero-icon,
:root[data-theme="dark"] .cat-child-icon {
    background: color-mix(in srgb, var(--cat-color, var(--c-primary)) 20%, var(--c-bg-soft));
}
:root[data-theme="dark"] .cat-child-card {
    background: var(--c-bg-card);
    border-color: var(--c-border);
}
:root[data-theme="dark"] .cat-child-card:hover {
    border-color: color-mix(in srgb, var(--cat-color, var(--c-primary)) 55%, transparent);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
}

/* 卡片用 #fff 硬编码的地方 */
:root[data-theme="dark"] .card,
:root[data-theme="dark"] .tool-card,
:root[data-theme="dark"] .feature,
:root[data-theme="dark"] .has-dropdown > .nav-dropdown,
:root[data-theme="dark"] .nav-user-menu,
:root[data-theme="dark"] .auth-toast {
    background: var(--c-bg-card);
    color: var(--c-text);
}

/* 输入框 */
:root[data-theme="dark"] input,
:root[data-theme="dark"] textarea,
:root[data-theme="dark"] select {
    background: rgba(255, 255, 255, 0.02);
    color: var(--c-text);
    border-color: var(--c-border);
}

/* 响应式：小屏按钮位置调整 */
@media (max-width: 520px) {
    .theme-toggle {
        right: 16px;
        bottom: 16px;
        width: 36px;
        height: 36px;
    }
}
