/* 导航栏样式在navbar.css中定义 */

/* 页面布局 */
.page-layout {
    display: grid;
    grid-template-columns: 250px 1fr 250px;
    gap: 2rem;
    max-width: 1600px;
    margin: 0 auto;
    padding: 2rem;
    position: relative;
    min-height: 100vh;
}

/* 左侧悬浮对话框 */
.floating-dialogs {
    position: sticky;
    top: 100px;
    height: fit-content;
}

.dialog {
    background-color: var(--card-bg);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    transition: all 0.3s;
    border: 1px solid var(--border-color);
    width: 90%;
    position: relative;
}

.dialog p {
    margin-bottom: 1rem;
    font-weight: 500;
    font-size: 1.2rem;
}

.dialog.hidden {
    display: none;
}

.continue-dialog {
    margin-top: 4rem;
}

/* Close button for dialogs */
.close-dialog-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: #666;
    transition: color 0.3s;
}

.close-dialog-btn:hover {
    color: #333;
}

/* 主要内容区域样式 */
.learning-content {
    padding: 2rem;
    background-color: var(--card-bg);
    border-radius: 8px;
    box-shadow: var(--card-shadow);
}

.learning-content h1 {
    font-size: 3rem;
    color: var(--heading-color);
    margin-bottom: 1.5rem;
    text-align: center;
    font-weight: 700;
}

.importance-scale {
    text-align: center;
    margin-bottom: 2rem;
    color: var(--text-color);
}

.stars {
    color: #ffd700;
    margin-left: 0.5rem;
}

/* 右侧导航栏 */
.side-nav {
    background-color: var(--card-bg);
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: var(--card-shadow);
}

.side-nav.sticky {
    position: sticky;
    top: 100px;
    height: fit-content;
}

.nav-header {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    margin-bottom: 1rem;
    min-height: 32px;
    gap: 1rem;
}

.nav-header h3 {
    margin: 0;
    white-space: nowrap;
    font-size: 1.1rem;
    line-height: 32px;
}

.hide-nav {
    background: none;
    border: 1px solid #e0e0e0;
    color: var(--link-color);
    cursor: pointer;
    font-size: 0.9rem;
    padding: 0.3rem 0.8rem;
    border-radius: 4px;
    width: 70px;
    min-width: 70px;
    text-align: center;
    flex-shrink: 0;
    height: 32px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-sizing: border-box;
    transition: all 0.3s;
}

.nav-content ul {
    list-style: none;
    padding: 0;
}

.nav-content a {
    display: block;
    padding: 0.5rem 0;
    color: var(--link-color);
    text-decoration: none;
    transition: color 0.3s;
}

.nav-content a:hover {
    color: var(--link-hover-color);
}

/* 内容区域样式 */
.content-sections {
    margin-top: 2rem;
}

.section {
    margin-bottom: 3rem;
    padding: 2rem;
    background-color: var(--card-bg);
    border-radius: 8px;
    box-shadow: var(--card-shadow);
    scroll-margin-top: 100px;
}

.section-header {
    display: flex;
    align-items: center;
    margin-bottom: 1.5rem;
}

.section-title {
    margin: 0;
    font-size: 2rem;
    color: var(--heading-color);
    font-weight: 600;
}

.section-stars {
    margin-left: 1rem;
    color: #ffd700;
}

.concept {
    margin-bottom: 2rem;
}

.concept h3 {
    color: var(--heading-color);
    margin-bottom: 1rem;
}

.math-content {
    background-color: var(--bg-color);
    padding: 1rem;
    border-radius: 4px;
    margin: 1rem 0;
    overflow-x: auto;
    font-size: 1.1rem;
    line-height: 1.6;
}

.exercise {
    margin-bottom: 2rem;
}

.exercise h3 {
    color: var(--heading-color);
    margin-bottom: 1rem;
}

.answer-section {
    margin-top: 1.5rem;
    min-height: 100px;
}

.show-answer-btn {
    background: none;
    reign-content: center;
    border: 2px solid #4a90e2;
    padding: 0.5rem 1.5rem;
    color: var(--text-color);
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.3s;
    margin-bottom: 1.5rem;
    font-weight: 500;
    font-size: 1.1rem;
}

.show-answer-btn:hover {
    background-color: var(--btn-secondary-bg);
}

.answer-content {
    display: none;
    margin-top: 1rem;
    padding: 1rem;
    background-color: var(--bg-color);
    border-radius: 4px;
    font-size: 1.1rem;
    line-height: 1.6;
}

.answer-content.visible {
    display: block;
}

/* 按钮样式 */
.btn {
    padding: 0.6rem 1.2rem;
    border-radius: 4px;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s;
    display: inline-block;
    margin: 0.5rem;
}

.primary-btn {
    background-color: #4a90e2;
    color: white;
}

.primary-btn:hover {
    background-color: #3a7bc8;
}

.secondary-btn {
    background-color: #f0f0f0;
    color: #333;
}

.secondary-btn:hover {
    background-color: #e0e0e0;
}



/* 面包屑导航样式 */
.breadcrumb {
    padding: 1rem 2rem;
    font-size: 0.9rem;
}

.breadcrumb a {
    color: #666;
    text-decoration: none;
}

.breadcrumb a:hover {
    color: #4a90e2;
    text-decoration: underline;
}

.breadcrumb span {
    color: var(--text-color);
    font-weight: 500;
}

/* Override link color in dark mode to match light mode behavior */
body.dark .breadcrumb a {
    color: #666;
}

body.dark .breadcrumb a:hover {
    color: var(--link-hover-color);
}

/* 专注模式样式 */
.focus-mode {
    max-width: 900px;
    box-sizing: border-box;
}

/* 专注模式下调整页面布局 */
.page-layout.focus-mode {
    display: grid;
    grid-template-columns: 0fr minmax(auto, 900px) 250px; /* 左侧收缩，中间限宽但不使用margin，右侧保持原宽 */
    gap: 2rem; /* 保持与原版相同的间距 */
    justify-content: center;
    margin: 0 auto; /* 居中整个布局 */
    max-width: 1400px; /* 限制最大宽度 */
}

/* 专注模式下内容区域不需要单独的margin */
.focus-mode .learning-content {
    grid-column: 2;
    margin: 0; /* 覆盖 .focus-mode 的 margin */
}

/* 专注模式下调整右侧导航栏位置 */
.focus-mode .side-nav {
    grid-column: 3;
    position: sticky;
    top: 100px;
    height: fit-content;
    width: 100%; /* 确保占满第三列 */
}

/* 在专注模式下隐藏左侧部分 */
.focus-mode .floating-dialogs {
    display: none;
    grid-column: 1;
}

/* 响应式设计 */
@media (max-width: 1200px) {
    .page-layout {
        grid-template-columns: 200px 1fr 200px;
        padding: 1rem;
    }

    .learning-content h1 {
        font-size: 2.5rem;
    }

    .section-title {
        font-size: 1.8rem;
    }

    .dialog p {
        font-size: 1.1rem;
    }

    .focus-mode {
        max-width: 900px;
    }
}

@media (max-width: 992px) {
    .page-layout {
        grid-template-columns: 200px 1fr 200px;
        gap: 1rem;
    }

    .floating-dialogs {
        position: static;
        margin-bottom: 1.5rem;
        width: 100%;
    }

    .dialog {
        width: 100%;
        padding: 1rem;
    }

    .learning-content {
        padding: 1.5rem;
    }

    .section {
        padding: 1.5rem;
        scroll-margin-top: 100px;
    }

    .page-layout.focus-mode {
        grid-template-columns: 0fr 1fr 200px;
    }

    .focus-mode {
        max-width: 85%;
    }
}

@media (max-width: 768px) {
    .navbar {
        padding: 1rem;
    }

    .logo a {
        font-size: 1.5rem;
    }

    .nav-links {
        position: fixed;
        top: 70px;
        left: -100%;
        width: 100%;
        height: calc(100vh - 70px);
        background-color: white;
        transition: left 0.3s;
        box-shadow: 0 5px 10px rgba(0,0,0,0.1);
        z-index: 999;
    }

    .nav-links.active {
        left: 0;
    }

    .nav-links ul {
        flex-direction: column;
        padding: 2rem;
    }

    .nav-links li {
        margin: 1rem 0;
    }

    .nav-links a {
        font-size: 1.1rem;
    }

    .mobile-menu-btn {
        display: block;
    }

    .language-switch {
        margin-left: auto;
        margin-right: 1rem;
    }

    .language-btn {
        padding: 0.2rem 0.6rem;
        font-size: 0.8rem;
    }

    .theme-toggle i {
        font-size: 1rem;
    }

    .learning-content {
        padding: 1rem;
    }

    .learning-content h1 {
        font-size: 2rem;
    }

    .section-title {
        font-size: 1.5rem;
    }

    .section {
        padding: 1rem;
        margin-bottom: 2rem;
        scroll-margin-top: 80px;
    }

    .math-content {
        font-size: 1rem;
        padding: 0.8rem;
    }

    .show-answer-btn {
        padding: 0.4rem 1rem;
        font-size: 1rem;
    }

    .answer-content {
        font-size: 1rem;
        padding: 0.8rem;
    }

    .nav-header {
        gap: 0.5rem;
    }

    .nav-header h3 {
        font-size: 1rem;
    }

    .hide-nav {
        width: 60px;
        min-width: 60px;
        height: 28px;
        font-size: 0.8rem;
        padding: 0.2rem 0.5rem;
    }

    .dialog p {
        font-size: 1rem;
    }

    .btn {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }

    /* Transform practice-dialog into a floating action button */
    .practice-dialog {
        position: fixed;
        bottom: 80px;
        right: 20px;
        width: 50px;
        height: 50px;
        border-radius: 50%;
        padding: 0;
        display: flex;
        justify-content: center;
        align-items: center;
        background-color: #4a90e2;
        border: none;
        box-shadow: 0 2px 5px rgba(0,0,0,0.2);
        z-index: 1000;
        transition: all 0.3s;
    }

    .practice-dialog:hover {
        background-color: #3a7bc8;
    }

    .practice-dialog p {
        display: none;
    }

    .practice-dialog .btn {
        display: none;
    }

    .practice-dialog::after {
        content: attr(data-practice-text);
        color: white;
        font-size: 0.8rem;
        font-weight: 500;
        text-align: center;
        line-height: 1.2;
        padding: 0.5rem;
    }

    /* Transform continue-dialog into a bottom popup */
    .continue-dialog {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 70px;
        max-width: 300px;
        padding: 1rem;
        border-radius: 0;
        margin: 0;
        background-color: var(--card-bg);
        box-shadow: 0 -2px 10px rgba(0,0,0,0.2);
        z-index: 1001;
        display: flex;
        flex-direction: column;
        align-items: flex-start;
    }

    .continue-dialog p {
        margin-bottom: 0.5rem;
        margin-top: 0;
    }

    .continue-dialog .btn {
        align-self: flex-start;
        margin: 0;
    }

    /* Side-nav styling when inside learning-content */
    .page-layout {
        grid-template-columns: 1fr;
    }

    .side-nav {
        margin-bottom: 1rem;
        padding: 1rem;
        width: 100%;
        position: static !important; /* 改为static定位 */
        /* 移除sticky相关的属性 */
        /* top: 80px !important; */
        z-index: 100;
        max-height: 70vh;
        overflow-y: auto;
    }

    .page-layout.focus-mode {
        grid-template-columns: 1fr;
    }

    .focus-mode .side-nav {
        grid-column: 1;
        margin-top: 1rem;
    }

    .focus-mode .learning-content {
        grid-column: 1;
    }
}

@media (max-width: 576px) {
    .navbar {
        padding: 0.5rem 0.8rem;
    }

    .logo a {
        font-size: 1.3rem;
    }

    .nav-links ul {
        padding: 1rem;
    }

    .nav-links a {
        font-size: 1rem;
    }

    .language-btn {
        padding: 0.2rem 0.5rem;
        font-size: 0.7rem;
    }

    .theme-toggle i {
        font-size: 0.9rem;
        margin: 0 0.2rem;
    }

    .mobile-menu-btn {
        font-size: 1.3rem;
    }

    .breadcrumb {
        padding: 0.5rem 0.8rem;
        font-size: 0.9rem;
    }

    .page-layout {
        padding: 0.8rem;
        gap: 0.8rem;
    }

    .learning-content {
        padding: 0.8rem;
    }

    .learning-content h1 {
        font-size: 1.8rem;
    }

    .importance-scale {
        font-size: 0.9rem;
    }

    .section {
        padding: 0.8rem;
        margin-bottom: 1.5rem;
        scroll-margin-top: 70px;
    }

    .section-title {
        font-size: 1.3rem;
    }

    .section-stars {
        font-size: 0.9rem;
    }

    .concept h3, .exercise h3 {
        font-size: 1.1rem;
    }

    .math-content {
        font-size: 0.9rem;
        padding: 0.6rem;
    }

    .show-answer-btn {
        padding: 0.3rem 0.8rem;
        font-size: 0.9rem;
    }

    .answer-content {
        font-size: 0.9rem;
        padding: 0.6rem;
    }

    .side-nav {
        padding: 0.8rem;
    }

    .nav-header h3 {
        font-size: 0.9rem;
    }

    .hide-nav {
        width: 55px;
        min-width: 55px;
        height: 26px;
        font-size: 0.7rem;
        padding: 0.2rem 0.4rem;
    }

    .nav-content a {
        font-size: 0.9rem;
        padding: 0.4rem 0;
    }

    .dialog {
        padding: 0.8rem;
    }

    .dialog p {
        font-size: 0.9rem;
    }

    .btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
    }

    footer {
        padding: 1.5rem 0.8rem;
    }

    .footer-content {
        font-size: 0.8rem;
        flex-direction: column;
        text-align: center;
    }

    /* Adjust the practice-dialog for smaller screens */
    .practice-dialog {
        width: 45px;
        height: 45px;
        bottom: 70px;
        right: 20px;
    }

    .practice-dialog::after {
        font-size: 0.7rem;
    }

    /* Adjust the continue-dialog for smaller screens */
    .continue-dialog {
        padding: 0.8rem;
        right: 65px;
        max-width: 280px;
    }

    .continue-dialog p {
        font-size: 0.9rem;
    }

    .continue-dialog .btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
    }

    .focus-mode {
        max-width: 100%;
        padding: 1rem;
    }

}