/* 公共 CSS 样式 */

/* 全局样式重置与基础设置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
}

body {
    background-color: #f8f5f0;
    color: #333;
    line-height: 1.6;
    padding: 0;
    padding-top: 70px;
}

/* 导航栏样式 */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background-color: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    z-index: 1000;
}

.navbar-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #8c6d31 0%, #d4af37 100%);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.2rem;
    font-weight: bold;
}

.site-name {
    font-size: 1.3rem;
    font-weight: 600;
    color: #8c6d31;
}

.navbar-nav {
    display: flex;
    list-style: none;
    gap: 8px;
    margin: 0;
    padding: 0;
}

.navbar-nav li {
    margin: 0;
}

.nav-link {
    display: block;
    padding: 8px 16px;
    color: #666;
    text-decoration: none;
    border-radius: 6px;
    transition: all 0.3s ease;
    font-size: 0.9rem;
    white-space: nowrap;
}

.nav-link:hover {
    background-color: #f8f5f0;
    color: #8c6d31;
}

.nav-link:active {
    background-color: #f0e8d6;
}

/* 移动端导航栏样式 - 导航链接底部固定 */
@media (max-width: 768px) {
    body {
        padding-top: 56px;
        padding-bottom: 60px;
    }

    .navbar {
        top: 0;
        bottom: auto;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
        border-top: none;
    }

    .navbar-container {
        height: 56px;
        padding: 0 12px;
        flex-wrap: nowrap;
        justify-content: space-between;
    }

    .navbar-brand {
        display: flex;
        flex-shrink: 0;
        gap: 8px;
    }

    .logo {
        width: 36px;
        height: 36px;
        font-size: 1.1rem;
        border-radius: 6px;
    }

    .site-name {
        font-size: 1.15rem;
        font-weight: 600;
    }

    /* 导航链接部分单独固定在底部 */
    .navbar-nav {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        display: flex;
        width: 100%;
        justify-content: space-around;
        gap: 0;
        padding: 0;
        margin: 0;
        background-color: #fff;
        box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.1);
        border-top: 1px solid #e8e8e8;
        z-index: 1000;
        height: 60px;
    }

    .navbar-nav li {
        flex: 1;
        display: flex;
        justify-content: center;
        margin: 0;
    }

    .nav-link {
        width: 100%;
        padding: 10px 8px;
        text-align: center;
        font-size: 0.85rem;
        border-radius: 0;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        min-height: 60px;
    }

    .nav-link:hover,
    .nav-link:active {
        background-color: #f8f5f0;
        color: #8c6d31;
    }

    .navbar-nav::-webkit-scrollbar {
        display: none;
    }
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding-right: 20px;
    padding-bottom: 20px;
    padding-left: 20px;
    gap: 20px;
    display: flex;
    flex-direction: column;
}

/* 页面标题样式 */
.page-title {
    text-align: center;
    padding: 15px 0;
    color: #8c6d31;
    border-bottom: 1px solid #e0d6c2;
    margin-bottom: 10px;
}

.page-title h1 {
    font-size: 2.2rem;
    margin-bottom: 10px;
    font-weight: 500;
}

.page-title .notice {
    font-size: 0.9rem;
    color: #666;
}

/* 卡片通用样式 */
.card {
    background-color: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    padding: 24px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border: 1px solid #f0e6d2;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
}

.card-header {
    color: #8c6d31;
    font-size: 1.4rem;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px dashed #e0d6c2;
    display: flex;
    align-items: center;
}

.card-header i {
    margin-right: 10px;
    font-size: 1.6rem;
}

.card-body {
    font-size: 1rem;
    color: #555;
}

.card-body.hidden {
    display: none;
}

/* 优化后的八字表格样式（横排四柱，竖排属性） */
.bazi-table-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch; /* iOS平滑滚动 */
    margin: 16px 0;
}

.bazi-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px; /* 确保表格最小宽度 */
}

.bazi-table th, .bazi-table td {
    padding: 12px;
    text-align: center; /* 居中对齐更美观，适配横竖排布局 */
    border: 1px solid #e0d6c2;
    white-space: nowrap; /* 防止内容换行，保持表格整洁 */
}

/* 神煞行允许换行，避免超出容器 */
.bazi-table tr.shensha-row td {
    white-space: normal; /* 允许换行，因为神煞内容较长 */
    word-wrap: break-word;
    word-break: break-all;
    line-height: 1.6;
    max-width: 0; /* 允许单元格自动调整宽度 */
    /* 字体大小、内边距等与其他行保持一致 */
}

/* 左侧属性列（竖排：十神、八字等） */
.bazi-table th:first-child {
    background-color: #faf5eb;
    color: #8c6d31;
    font-weight: 500;
    text-align: center; /* 属性列居中对齐，与四柱列统一 */
    width: 120px; /* 固定属性列宽度，优化布局 */
}

/* 四柱列（横排：年/月/日/时柱）表头 */
.bazi-table th:not(:first-child) {
    background-color: #faf5eb;
    color: #8c6d31;
    font-weight: 500;
}

/* 偶数行背景色优化，提升可读性 */
.bazi-table tr:nth-child(even) {
    background-color: #fcfaf6;
}

/* 大运列表样式 - 3行4列布局 */
.dayun-list {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-top: 16px;
}

.dayun-item {
    background-color: #faf5eb;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid #e0d6c2;
}

.dayun-item .title {
    color: #8c6d31;
    font-weight: 500;
    margin-bottom: 6px;
}

/* 响应式调整 - 移动端适配 */
@media (max-width: 768px) {
    body {
        padding: 0;
        padding-top: 56px;
    }
    
    .container {
        padding: 10px;
    }

    .page-title h1 {
        font-size: 1.8rem;
    }

    .card {
        padding: 18px;
    }

    .card-header {
        font-size: 1.2rem;
    }

    .card-body {
        padding: 0;
    }

    .bazi-table-wrapper {
        margin: 12px 0; /* 移动端不需要负边距 */
        width: 100%;
        overflow-x: visible; /* 移除横向滚动 */
    }

    .bazi-table {
        min-width: 0; /* 移除最小宽度限制，让表格自适应屏幕 */
        width: 100%; /* 确保表格宽度为100% */
        table-layout: auto; /* 允许列宽根据内容自适应 */
    }

    .bazi-table th, .bazi-table td {
        padding: 6px 4px;
        font-size: 0.85rem;
        width: auto; /* 移动端允许自动调整宽度 */
        box-sizing: border-box; /* 确保padding包含在宽度内 */
    }

    .bazi-table th:first-child,
    .bazi-table td:first-child {
        min-width: 0; /* 移动端属性列最小宽度设为0，根据内容自适应 */
        width: auto;
        padding: 4px 1px; /* 减小内边距，让列更窄 */
        font-size: 0.8rem;
        white-space: nowrap; /* 防止文字换行 */
    }

    .bazi-table th:not(:first-child),
    .bazi-table td:not(:first-child) {
        min-width: 0; /* 移动端四柱列最小宽度设为0，根据内容自适应 */
    }

    /* 移动端第二列（年柱）设置为最窄，根据文字长度自适应 */
    .bazi-table th:nth-child(2),
    .bazi-table td:nth-child(2) {
        min-width: 0;
        width: auto;
        max-width: fit-content;
        padding: 4px 1px;
        white-space: nowrap;
    }

    /* 移动端第三、四、五列（月柱、日柱、时柱）设置为最窄，根据文字长度自适应 */
    .bazi-table th:nth-child(3),
    .bazi-table td:nth-child(3),
    .bazi-table th:nth-child(4),
    .bazi-table td:nth-child(4),
    .bazi-table th:nth-child(5),
    .bazi-table td:nth-child(5) {
        min-width: 0;
        width: auto;
        max-width: fit-content;
        padding: 4px 1px;
        white-space: nowrap;
    }

    /* 移动端神煞行与其他行统一样式，只保留允许换行的设置 */
    .bazi-table tr.shensha-row td {
        white-space: normal; /* 允许换行，因为神煞内容较长 */
        /* 字体大小、内边距等完全继承其他行的设置 */
    }

    /* 移动端神煞行非第一列单元格，根据内容自适应宽度，强制覆盖其他规则 */
    .bazi-table tr.shensha-row td:not(:first-child) {
        min-width: 0 !important;
        width: auto !important;
        max-width: none !important;
    }

    /* 移动端神煞行的表头，也移除最小宽度限制 */
    .bazi-table thead tr th:nth-child(2),
    .bazi-table thead tr th:nth-child(3),
    .bazi-table thead tr th:nth-child(4),
    .bazi-table thead tr th:nth-child(5) {
        min-width: 0 !important;
    }

    /* 移动端大运列表改为单列 */
    .dayun-list {
        grid-template-columns: 1fr;
    }
}

/* 底部版权样式 */
.footer {
    background-color: #fff;
    border-top: 1px solid #e0d6c2;
    padding: 30px 20px;
    margin-top: 10px;
    text-align: center;
}

.footer-container {
    max-width: 1200px;
    margin: 0 auto;
}

.footer .copyright {
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 8px;
}

.footer .notice {
    color: #999;
    font-size: 0.85rem;
    font-style: italic;
}

/* 移动端底部版权样式 */
@media (max-width: 768px) {
    .footer {
        padding: 20px 15px 80px 15px; /* 增加底部padding，避免被固定导航栏遮挡 */
        margin-top: 30px;
    }

    .footer .copyright {
        font-size: 0.85rem;
        margin-bottom: 6px;
    }

    .footer .notice {
        font-size: 0.8rem;
    }
}

/* 回到顶部按钮 */
.back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    background-color: #8c6d31;
    color: #fff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
    z-index: 999;
    font-size: 1.2rem;
}

.back-to-top:hover {
    background-color: #7a5d28;
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.back-to-top:active {
    transform: translateY(-1px);
}

.back-to-top.show {
    display: flex;
}

/* 移动端回到顶部按钮 */
@media (max-width: 768px) {
    .back-to-top {
        bottom: 80px; /* 避免被底部导航栏遮挡 */
        right: 20px;
        width: 45px;
        height: 45px;
        font-size: 1rem;
    }
}