/* ============================================================
 * 金考题 Web 端公共布局层（layout）
 * 依赖：theme.css → base.css → components.css → 本文件
 * 承载：header / footer / main-content / quick_access / 用户中心外壳
 * （自 header.php / footer.php / quick_access.php / user/layout.php 内联样式抽取）
 * ============================================================ */

/* ============================================================
 * 顶部导航条
 * ============================================================ */
.header {
    background: var(--bg-card);
    box-shadow: var(--shadow-sm);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: var(--z-header);
}

.header-content {
    max-width: var(--container);
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-5);
    padding: 12px 20px;
}

/* Logo（height 收敛至 48px，header 实际高度 = 72px 对齐 --header-h） */
.logo {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.logo img {
    height: 48px;
    width: auto;
    display: block;
}

/* 旧导航（阶段 2b 起由 .jk-nav 取代，规则暂留兼容） */
.nav-menu {
    display: flex;
    gap: var(--sp-6);
    list-style: none;
}

.nav-menu a {
    text-decoration: none;
    color: var(--text-primary);
    font-size: var(--fs-lg);
    transition: color var(--t-base) var(--ease);
}

.nav-menu a:hover {
    color: var(--primary);
}

/* ============================================================
 * 全局搜索
 * ============================================================ */
.search-container {
    display: flex;
    align-items: center;
    position: relative;
    width: 420px;
    flex: 1;
    max-width: 420px;
}

.search-input {
    width: 100%;
    padding: 8px 36px 8px var(--sp-3);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-md);
    outline: none;
    background: var(--bg-card);
    font-size: var(--fs-md);
    transition: border-color var(--t-base) var(--ease),
                box-shadow var(--t-base) var(--ease);
}

.search-input::placeholder {
    color: var(--gray-400);
}

.search-input:focus {
    border-color: var(--primary);
    box-shadow: var(--ring);
}

.search-icon {
    position: absolute;
    right: 10px;
    color: var(--gray-400);
    pointer-events: none;
}

.search-dropdown {
    position: absolute;
    top: 42px;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: var(--z-dropdown);
    display: none;
    max-height: 420px;
    overflow-y: auto;
}

.search-group-title {
    font-size: var(--fs-xs);
    color: var(--text-muted);
    padding: var(--sp-2) var(--sp-3);
    background: var(--gray-50);
    border-bottom: 1px solid var(--border-light);
}

.search-item {
    padding: 10px var(--sp-3);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    transition: background-color var(--t-fast) var(--ease);
}

.search-item:hover {
    background: var(--bg-hover);
}

.search-item .meta {
    color: var(--gray-400);
    font-size: var(--fs-xs);
}

.search-empty {
    padding: var(--sp-3);
    color: var(--gray-400);
}

.search-more {
    padding: 10px var(--sp-3);
    text-align: center;
    border-top: 1px dashed var(--border-medium);
}

.search-more a {
    color: var(--primary);
    text-decoration: none;
}

.search-kbd {
    border: 1px solid var(--border-medium);
    padding: 0 6px;
    border-radius: 4px;
    font-size: var(--fs-xs);
    color: var(--text-muted);
}

/* ============================================================
 * 用户区（登录按钮 / 头像下拉）
 * legacy.js 契约：#auth-buttons / #user-info / .user-dropdown(.show)
 * ============================================================ */
.user-section {
    display: flex;
    align-items: center;
    gap: var(--sp-5);
    flex-shrink: 0;
}

/* 未登录 */
.auth-buttons {
    display: flex;
    gap: var(--sp-2);
}

.auth-btn {
    padding: 8px var(--sp-4);
    border-radius: var(--radius-md);
    text-decoration: none;
    font-size: var(--fs-md);
    transition: color var(--t-base) var(--ease),
                background-color var(--t-base) var(--ease),
                border-color var(--t-base) var(--ease),
                box-shadow var(--t-base) var(--ease);
}

.login-btn {
    color: var(--primary);
    border: 1px solid var(--primary-tint-border);
    background: transparent;
}

.login-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    box-shadow: var(--shadow-primary);
}

/* 已登录 */
.user-info {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    cursor: pointer;
    position: relative;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: var(--fs-lg);
    font-weight: var(--fw-semibold);
    overflow: hidden;
    flex-shrink: 0;
}

.user-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.user-details {
    display: flex;
    flex-direction: column;
}

.user-nickname {
    font-size: var(--fs-md);
    font-weight: var(--fw-medium);
    color: var(--text-primary);
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-status {
    font-size: var(--fs-xs);
    color: var(--text-muted);
}

/* 用户下拉菜单（.show 为 legacy.js 契约类，勿改名） */
.user-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    min-width: 176px;
    padding: var(--sp-1);
    display: none;
    z-index: var(--z-dropdown);
}

.user-dropdown.show {
    display: block;
}

.dropdown-item {
    padding: 10px var(--sp-3);
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--text-secondary);
    font-size: var(--fs-md);
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    transition: background-color var(--t-fast) var(--ease),
                color var(--t-fast) var(--ease);
}

.dropdown-item:hover {
    background: var(--primary-tint-bg);
    color: var(--primary-tint-text);
}

.dropdown-item i {
    width: 18px;
    text-align: center;
    color: var(--gray-400);
    transition: color var(--t-fast) var(--ease);
}

.dropdown-item:hover i {
    color: var(--primary);
}

.dropdown-divider {
    height: 1px;
    background: var(--border-light);
    margin: var(--sp-1) 0;
}

/* ============================================================
 * 主内容区
 * ============================================================ */
.main-content {
    margin-top: var(--main-offset);
    max-width: var(--container);
    margin-left: auto;
    margin-right: auto;
    padding: var(--sp-5);
}

/* ============================================================
 * 页脚
 * ============================================================ */
.footer {
    background: var(--gray-50);
    border-top: 1px solid var(--border-light);
    margin-top: var(--sp-10);
    padding: var(--sp-8) var(--sp-5);
    text-align: center;
    color: var(--text-muted);
}

.footer-content {
    max-width: var(--container);
    margin: 0 auto;
}

.footer-links {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: var(--sp-6);
    margin-bottom: var(--sp-5);
}

.footer-links a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: var(--fs-md);
    transition: color var(--t-base) var(--ease);
}

.footer-links a:hover {
    color: var(--primary);
}

.footer-copyright {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: var(--sp-2);
    font-size: var(--fs-sm);
}

.footer-copyright a {
    color: var(--text-muted);
    text-decoration: none;
    transition: color var(--t-base) var(--ease);
}

.footer-copyright a:hover {
    color: var(--primary);
}

.footer-logo-icon {
    width: 16px;
    height: 16px;
    vertical-align: -2px;
}

.footer-beian {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--text-muted);
    text-decoration: none;
    transition: color var(--t-base) var(--ease);
}

.footer-beian:hover {
    color: var(--primary);
}

.footer-beian-icon {
    height: 18px;
    width: auto;
}

/* ============================================================
 * 首页右栏：快速入口（quick_access.php）
 * ============================================================ */
.quick-access {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: var(--sp-5);
    margin-bottom: var(--sp-5);
    box-shadow: var(--shadow-xs);
}

.quick-access h3 {
    font-size: var(--fs-lg);
    font-weight: var(--fw-semibold);
    margin-bottom: var(--sp-4);
    color: var(--text-primary);
}

.quick-links {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--sp-2);
}

.quick-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-3) var(--sp-2);
    border-radius: var(--radius-md);
    text-decoration: none;
    color: var(--text-secondary);
    font-size: var(--fs-xs);
    transition: background-color var(--t-base) var(--ease),
                transform var(--t-base) var(--ease),
                box-shadow var(--t-base) var(--ease);
}

.quick-link:hover {
    background: var(--primary-tint-bg);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.quick-link i {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    background: var(--primary-tint-bg);
    color: var(--primary);
    font-size: var(--fs-md);
}

.quick-link:hover i {
    background: var(--bg-card);
}

/* APP 下载区（DOM 暂注释，样式保留） */
.app-section {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: var(--sp-5);
    box-shadow: var(--shadow-xs);
}

.app-section h3 {
    font-size: var(--fs-lg);
    font-weight: var(--fw-semibold);
    margin-bottom: var(--sp-4);
    color: var(--text-primary);
}

.app-qr {
    width: 120px;
    height: 120px;
    background: var(--gray-100);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto var(--sp-4);
    color: var(--gray-400);
}

.download-btn {
    width: 100%;
    padding: var(--sp-3);
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-md);
    font-size: var(--fs-md);
    cursor: pointer;
    transition: background-color var(--t-base) var(--ease),
                box-shadow var(--t-base) var(--ease);
}

.download-btn:hover {
    background: var(--primary-hover);
    box-shadow: var(--shadow-primary);
}

/* ============================================================
 * 首页右栏：考试资讯（quick_access.php）
 * ============================================================ */
.exam-news-section {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: var(--sp-5);
    margin-bottom: var(--sp-5);
    box-shadow: var(--shadow-xs);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--sp-4);
}

.section-header h3 {
    font-size: var(--fs-lg);
    font-weight: var(--fw-semibold);
    margin: 0;
    color: var(--text-primary);
}

.view-all {
    font-size: var(--fs-sm);
    color: var(--primary);
    text-decoration: none;
    transition: color var(--t-base) var(--ease);
}

.view-all:hover {
    color: var(--primary-hover);
}

.news-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.news-item {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-2) var(--sp-2);
    border-radius: var(--radius-sm);
    transition: background-color var(--t-fast) var(--ease);
}

.news-item:hover {
    background: var(--bg-hover);
}

.news-type {
    font-size: var(--fs-xs);
    color: var(--primary-tint-text);
    font-weight: var(--fw-medium);
    white-space: nowrap;
}

.news-title {
    flex: 1;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: var(--fs-md);
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: color var(--t-fast) var(--ease);
}

.news-title:hover {
    color: var(--primary);
}

.news-time {
    font-size: var(--fs-xs);
    color: var(--text-muted);
    white-space: nowrap;
}

.no-news {
    text-align: center;
    color: var(--text-muted);
    font-size: var(--fs-md);
    padding: var(--sp-5) 0;
}

/* ============================================================
 * 用户中心外壳（user/layout.php）
 * ============================================================ */
.user-center-container {
    max-width: var(--container);
    margin: 0 auto;
    padding: var(--sp-5);
    display: flex;
    gap: var(--sp-5);
    align-items: stretch;
}

/* 侧边导航 */
.sidebar {
    width: var(--sidebar-w);
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
    padding: var(--sp-3) 0;
    height: fit-content;
    position: sticky;
    top: calc(var(--header-h) + var(--sp-2));
    flex-shrink: 0;
}

.sidebar-nav {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-nav-item {
    margin: 0;
}

.sidebar-nav-link {
    display: flex;
    align-items: center;
    padding: 13px var(--sp-5);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: var(--fs-md);
    transition: background-color var(--t-base) var(--ease),
                color var(--t-base) var(--ease);
    border-left: 3px solid transparent;
}

.sidebar-nav-link:hover {
    background: var(--bg-hover);
    color: var(--primary);
}

.sidebar-nav-link.active {
    background: var(--primary-tint-bg);
    color: var(--primary-tint-text);
    font-weight: var(--fw-medium);
    border-left-color: var(--primary);
}

.sidebar-nav-icon {
    width: 20px;
    margin-right: var(--sp-3);
    font-size: var(--fs-lg);
}

/* 主内容区域 */
.profile-content {
    flex: 1;
    min-width: 0;
}

.content-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
    padding: var(--sp-8);
    min-height: calc(100vh - 180px);
}

.content-header {
    margin-bottom: var(--sp-8);
    padding-bottom: var(--sp-5);
    border-bottom: 1px solid var(--border-light);
}

.content-header h2 {
    font-size: var(--fs-3xl);
    font-weight: var(--fw-semibold);
    color: var(--text-primary);
    margin: 0;
}

.content-header p {
    color: var(--text-secondary);
    margin: var(--sp-2) 0 0 0;
    font-size: var(--fs-md);
}

/* ============================================================
 * 响应式（导航横滚替代隐藏 / 搜索框缩窄）
 * ============================================================ */
@media (max-width: 992px) {
    .header-content {
        gap: var(--sp-3);
    }

    .search-container {
        max-width: 220px;
    }

    .nav-menu,
    .jk-nav {
        overflow-x: auto;
        scrollbar-width: none;
    }

    .nav-menu::-webkit-scrollbar,
    .jk-nav::-webkit-scrollbar {
        display: none;
    }
}

@media (max-width: 768px) {
    .search-container {
        display: none;
    }

    .user-details {
        display: none;
    }

    .user-center-container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        position: static;
    }

    .sidebar-nav {
        display: flex;
        overflow-x: auto;
    }

    .sidebar-nav-item {
        white-space: nowrap;
    }

    .sidebar-nav-link {
        border-left: none;
        border-bottom: 3px solid transparent;
    }

    .sidebar-nav-link.active {
        border-left-color: transparent;
        border-bottom-color: var(--primary);
    }
}
