/* ==========================================
   数独网站 - 完整样式表
   Version: 1.0.2
   ========================================== */

/* ==========================================
   CSS 变量定义
   ========================================== */
:root {
    --sidebar-width: 300px;
}

/* ==========================================
   主题颜色 - 浅色主题
   ========================================== */
.theme-light {
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-body: #f5f5f5;
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --border-color: #dee2e6;
    --sidebar-bg: #f8f9fa;
    --active-bg: #e7f3ff;
    --active-color: #0d6efd;
    --hover-bg: rgba(0,0,0,0.05);
}

/* ==========================================
   主题颜色 - 中等主题
   ========================================== */
.theme-medium {
    --bg-primary: #e9ecef;
    --bg-secondary: #dee2e6;
    --bg-body: #d3d7dc;
    --text-primary: #212529;
    --text-secondary: #495057;
    --border-color: #adb5bd;
    --sidebar-bg: #dee2e6;
    --active-bg: #cfe2ff;
    --active-color: #084298;
    --hover-bg: rgba(0,0,0,0.075);
}

/* ==========================================
   主题颜色 - 深色主题
   ========================================== */
.theme-dark {
    --bg-primary: #212529;
    --bg-secondary: #343a40;
    --bg-body: #1a1d20;
    --text-primary: #f8f9fa;
    --text-secondary: #adb5bd;
    --border-color: #495057;
    --sidebar-bg: #343a40;
    --active-bg: #0d6efd;
    --active-color: #ffffff;
    --hover-bg: rgba(255,255,255,0.1);
}

/* ==========================================
   全局样式
   ========================================== */
* {
    box-sizing: border-box;
}

body {
    background-color: var(--bg-body);
    color: var(--text-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
    margin: 0;
    padding: 0;
    min-height: 100vh;
}

/* ==========================================
   主容器布局
   ========================================== */
.main-container {
    display: flex;
    max-width: 1400px;
    margin: 0 auto;
    background-color: transparent;
}

/* ==========================================
   侧边栏样式
   ========================================== */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    height: 100vh;
    position: sticky;
    top: 0;
    overflow-y: auto;
    transition: background-color 0.3s ease;
    box-shadow: 2px 0 8px rgba(0,0,0,0.05);
}

.sidebar-content {
    padding: 2rem;
}

/* ==========================================
   Logo 样式
   ========================================== */
.logo-container {
    text-align: center;
    margin-bottom: 2rem;
}

/* 侧边栏 Logo - 更大尺寸 */
.sidebar .logo {
    max-width: 100%;
    width: 270px;
    height: auto;
}

/* 顶部菜单 Logo */
.logo-top {
    height: 65px;
    width: auto;
}

/* Offcanvas 菜单 Logo */
.logo-offcanvas {
    height: 50px;
    width: auto;
}

/* 根据主题显示对应的 Logo */
.theme-light .logo-light {
    display: block !important;
}

.theme-light .logo-medium,
.theme-light .logo-dark {
    display: none !important;
}

.theme-medium .logo-medium {
    display: block !important;
}

.theme-medium .logo-light,
.theme-medium .logo-dark {
    display: none !important;
}

.theme-dark .logo-dark {
    display: block !important;
}

.theme-dark .logo-light,
.theme-dark .logo-medium {
    display: none !important;
}

/* ==========================================
   导航菜单样式
   ========================================== */
.sidebar-nav {
    margin-top: 1.5rem;
}

.nav-item {
    display: block;
    padding: 0.75rem 1rem;
    margin-bottom: 0.25rem;
    color: var(--text-primary);
    text-decoration: none;
    border-radius: 0.375rem;
    transition: all 0.2s ease;
    cursor: pointer;
}

.nav-item:hover {
    background-color: var(--hover-bg);
    color: var(--text-primary);
    text-decoration: none;
}

.nav-item.active {
    background-color: var(--active-bg);
    color: var(--active-color);
    font-weight: 600;
    pointer-events: none;
    cursor: default;
}

.nav-item-indent {
    padding-left: 2rem;
    font-size: 0.95rem;
}

.nav-section {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    margin-top: 1rem;
    padding: 0 1rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* 外部链接样式 */
.nav-item.external-link {
    font-size: 0.9rem;
    opacity: 0.85;
    font-weight: 400;
}

.nav-item.external-link:hover {
    opacity: 1;
}

.nav-item.external-link i {
    font-size: 0.7rem;
    opacity: 0.6;
}

/* ==========================================
   主题切换器样式
   ========================================== */
.theme-switcher {
    display: flex;
    gap: 0.5rem;
    padding-top: 1.5rem;
    margin-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.btn-theme {
    flex: 1;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.5rem;
    transition: all 0.2s ease;
    cursor: pointer;
    border-radius: 0.375rem;
}

.btn-theme:hover {
    background-color: var(--hover-bg);
    transform: translateY(-2px);
}

.btn-theme.active {
    background-color: var(--active-color);
    color: white;
    border-color: var(--active-color);
}

.btn-theme i {
    font-size: 1.2rem;
}

/* ==========================================
   主内容区域样式
   ========================================== */
.main-content {
    flex: 1;
    padding: 2rem;
    min-height: 100vh;
    background-color: var(--bg-primary);
    transition: background-color 0.3s ease;
    box-shadow: 0 0 20px rgba(0,0,0,0.05);
}

/* ==========================================
   语言选择器样式
   ========================================== */
.language-selector {
    margin-bottom: 2rem;
    text-align: right;
}

.language-selector .dropdown-toggle {
    border-color: var(--border-color);
    color: var(--text-primary);
    background-color: var(--bg-secondary);
    transition: all 0.2s ease;
}

.language-selector .dropdown-toggle:hover {
    background-color: var(--hover-bg);
}

.language-selector .dropdown-menu {
    background-color: var(--bg-primary);
    border-color: var(--border-color);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.language-selector .dropdown-item {
    color: var(--text-primary);
    transition: background-color 0.2s ease;
}

.language-selector .dropdown-item:hover {
    background-color: var(--hover-bg);
}

/* ==========================================
   游戏容器样式
   ========================================== */
.game-container {
    background-color: var(--bg-secondary);
    border-radius: 0.5rem;
    padding: 1rem;
    margin: 2rem 0;
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

.game-frame {
    width: 100%;
    height: 600px;
    border: none;
    border-radius: 0.5rem;
    background-color: white;
}

/* 宽屏时游戏固定大小并居中 */
@media (min-width: 1200px) {
    .game-frame {
        width: 600px;
        height: 600px;
        display: block;
        margin: 0 auto;
    }
}

/* ==========================================
   顶部菜单样式（移动端）
   ========================================== */
.top-menu {
    background-color: var(--sidebar-bg);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem;
    margin-bottom: 1rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    transition: background-color 0.3s ease;
}

.navbar-brand {
    margin: 0;
    padding: 0;
}

.navbar-toggler {
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    background-color: transparent;
}

.navbar-toggler:focus {
    box-shadow: none;
    outline: none;
}

/* ==========================================
   Offcanvas 样式（移动端侧边菜单）
   ========================================== */
.offcanvas {
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    transition: background-color 0.3s ease;
}

.offcanvas-header {
    border-bottom: 1px solid var(--border-color);
    padding: 1.25rem;
}

.offcanvas-title {
    margin: 0;
    display: flex;
    align-items: center;
}

.offcanvas-body {
    padding: 0;
}

.offcanvas-body .sidebar-content {
    padding: 1.5rem;
}

.btn-close {
    filter: var(--bs-btn-close-filter, none);
}

.theme-dark .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}

/* ==========================================
   页脚样式
   ========================================== */
.footer {
    margin-top: 4rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* ==========================================
   响应式设计
   ========================================== */

/* 平板和以下设备 */
@media (max-width: 991px) {
    .main-content {
        padding: 1rem;
        box-shadow: none;
    }

    .sidebar {
        display: none;
    }

    .game-container {
        padding: 0.5rem;
    }
    
    /* 移动端 Logo 尺寸调整 */
    .logo-top {
        height: 55px;
    }
}

/* 手机设备 */
@media (max-width: 576px) {
    .main-content {
        padding: 0.5rem;
    }

    .game-frame {
        height: 500px;
    }

    .language-selector {
        text-align: center;
        margin-bottom: 1rem;
    }
    
    /* 小屏幕进一步缩小 */
    .logo-top {
        height: 50px;
    }
    
    .logo-offcanvas {
        height: 45px;
    }
    
    .footer {
        margin-top: 2rem;
        font-size: 0.8rem;
    }
}

/* 超宽屏优化 */
@media (min-width: 1600px) {
    .main-container {
        max-width: 1600px;
    }
}

/* ==========================================
   工具类
   ========================================== */

/* 平滑滚动 */
html {
    scroll-behavior: smooth;
}

/* 自定义滚动条（仅 Webkit 浏览器） */
.sidebar::-webkit-scrollbar {
    width: 8px;
}

.sidebar::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

.sidebar::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* ==========================================
   标题样式
   ========================================== */
h1, h2, h3, h4, h5, h6 {
    color: var(--text-primary);
    margin-bottom: 1rem;
    transition: color 0.3s ease;
}

h1 {
    font-size: 2.5rem;
    font-weight: 700;
    line-height: 1.2;
}

h2 {
    font-size: 2rem;
    font-weight: 600;
    line-height: 1.3;
}

h3 {
    font-size: 1.5rem;
    font-weight: 600;
}

h4 {
    font-size: 1.25rem;
    font-weight: 600;
}

/* ==========================================
   段落和文本
   ========================================== */
p {
    line-height: 1.6;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.lead {
    font-size: 1.15rem;
    font-weight: 400;
    line-height: 1.7;
}

a {
    color: var(--active-color);
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: var(--text-primary);
    text-decoration: underline;
}

/* ==========================================
   卡片样式
   ========================================== */
.card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
    border-radius: 0.5rem;
}

.card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    transform: translateY(-2px);
}

.card-header {
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 1.25rem;
}

.card-body {
    padding: 1.25rem;
}

/* ==========================================
   按钮样式覆盖
   ========================================== */
.btn {
    transition: all 0.2s ease;
}

.btn-outline-secondary {
    color: var(--text-primary);
    border-color: var(--border-color);
    background-color: transparent;
}

.btn-outline-secondary:hover {
    background-color: var(--hover-bg);
    border-color: var(--border-color);
    color: var(--text-primary);
}

.btn-outline-secondary:focus {
    box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.25);
}

/* ==========================================
   Alert 样式
   ========================================== */
.alert {
    border-radius: 0.5rem;
    border: 1px solid transparent;
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
}

.alert-info {
    background-color: #d1ecf1;
    border-color: #bee5eb;
    color: #0c5460;
}

.theme-dark .alert-info {
    background-color: #17a2b8;
    border-color: #117a8b;
    color: white;
}

.alert-warning {
    background-color: #fff3cd;
    border-color: #ffeeba;
    color: #856404;
}

.theme-dark .alert-warning {
    background-color: #ffc107;
    border-color: #e0a800;
    color: #212529;
}

.alert-success {
    background-color: #d4edda;
    border-color: #c3e6cb;
    color: #155724;
}

.theme-dark .alert-success {
    background-color: #28a745;
    border-color: #23923d;
    color: white;
}

/* ==========================================
   表单样式
   ========================================== */
.form-control {
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    transition: all 0.2s ease;
}

.form-control:focus {
    background-color: var(--bg-primary);
    border-color: var(--active-color);
    color: var(--text-primary);
    box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.25);
}

.form-control::placeholder {
    color: var(--text-secondary);
    opacity: 0.6;
}

/* ==========================================
   表格样式
   ========================================== */
.table {
    color: var(--text-primary);
    border-color: var(--border-color);
}

.table thead {
    background-color: var(--bg-secondary);
}

.table tbody tr {
    transition: background-color 0.2s ease;
}

.table tbody tr:hover {
    background-color: var(--hover-bg);
}

/* ==========================================
   下拉菜单样式
   ========================================== */
.dropdown-menu {
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    border-radius: 0.5rem;
}

.dropdown-item {
    color: var(--text-primary);
    transition: background-color 0.2s ease;
}

.dropdown-item:hover,
.dropdown-item:focus {
    background-color: var(--hover-bg);
    color: var(--text-primary);
}

.dropdown-divider {
    border-color: var(--border-color);
}

/* ==========================================
   加载动画（可选）
   ========================================== */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid var(--border-color);
    border-radius: 50%;
    border-top-color: var(--active-color);
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ==========================================
   打印样式
   ========================================== */
@media print {
    .sidebar,
    .top-menu,
    .language-selector,
    .theme-switcher,
    .footer {
        display: none !important;
    }
    
    .main-content {
        padding: 0;
        box-shadow: none;
    }
    
    body {
        background-color: white;
    }
}

/* ==========================================
   辅助功能 / 可访问性
   ========================================== */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* 焦点可见性 */
*:focus-visible {
    outline: 2px solid var(--active-color);
    outline-offset: 2px;
}

/* ==========================================
   动画效果
   ========================================== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.3s ease-in-out;
}

/* ==========================================
   END OF STYLESHEET
   ========================================== */


@media (max-width: 414px) {
  .top-menu .logo-top { height: 48px; }
  .top-menu .container-fluid { gap: 8px; }
}

