/* ============================================================
   桂阳吴氏 · 家谱系统 - 主样式表
   ============================================================ */

/* ------ CSS 变量 ------ */
:root {
    --color-primary: #1a1a2e;
    --color-primary-light: #16213e;
    --color-accent: #0f3460;
    --color-accent-light: #e94560;
    --color-gold: #c9a84c;
    --color-bg: #f5f7fa;
    --color-card: #ffffff;
    --color-text: #2d3436;
    --color-text-light: #636e72;
    --color-border: #e1e4e8;
    --color-success: #27ae60;
    --color-error: #e74c3c;
    --color-warning: #f39c12;
    --radius: 12px;
    --shadow: 0 2px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
}

/* ------ 基础重置 ------ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    min-height: 100vh;
}
a { color: var(--color-accent); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--color-accent-light); }
img { max-width: 100%; height: auto; }

/* ------ 布局 ------ */
.app-container { display: flex; flex-direction: column; min-height: 100vh; }
.main-content { flex: 1; padding: 0; width: 100%; }

/* ------ 顶栏 ------ */
.main-header {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-accent) 100%);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 10px rgba(0,0,0,0.15);
}
.header-inner {
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
}
.logo a { color: #fff; text-decoration: none; }
.logo h1 {
    font-size: 20px;
    font-weight: 700;
    background: linear-gradient(135deg, #fff, var(--color-gold));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: 2px;
}
.main-nav { display: flex; align-items: center; gap: 8px; }
.main-nav a {
    color: rgba(255,255,255,0.85);
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 14px;
    transition: all 0.2s;
}
.main-nav a:hover {
    background: rgba(255,255,255,0.15);
    color: #fff;
}
/* ====== 管理下拉菜单 ====== */
.nav-admin-trigger { position: relative; display: inline-block; }
.admin-toggle { cursor: pointer; user-select: none; }
.nav-admin-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    min-width: 160px;
    background: #fff;
    border: 1.5px solid #d4b8a0;
    border-radius: 10px;
    box-shadow: 0 8px 30px rgba(90,62,43,0.2);
    flex-direction: column;
    padding: 6px;
    z-index: 2000;
    margin-top: 6px;
}
.nav-admin-dropdown a {
    color: #5a4a3a !important;
    padding: 8px 14px !important;
    border-radius: 6px;
    font-size: 14px;
    white-space: nowrap;
    transition: background 0.15s;
}
.nav-admin-dropdown a:hover { background: #f5ede4 !important; color: #5a3e2b !important; }
.dropdown-divider { height: 1px; background: #f0e6dc; margin: 4px 8px; }

.user-info {
    color: var(--color-gold);
    font-size: 13px;
    margin-left: 12px;
    padding-left: 12px;
    border-left: 1px solid rgba(255,255,255,0.2);
}


/* ------ 底部栏 ------ */
.main-footer {
    background: var(--color-primary);
    color: rgba(255,255,255,0.6);
    text-align: center;
    padding: 20px;
    font-size: 13px;
    margin-top: auto;
}
.main-footer p { margin: 0; }

/* ------ 页面头部 ------ */
.page-header {
    background: linear-gradient(135deg, rgba(26,26,46,0.03) 0%, rgba(15,52,96,0.05) 100%);
    border-bottom: 1px solid var(--color-border);
    padding: 20px 24px;
}
.page-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.page-header h2 { font-size: 20px; font-weight: 600; color: var(--color-primary); }
.breadcrumb { font-size: 13px; color: var(--color-text-light); margin-bottom: 6px; }
.breadcrumb a { color: var(--color-accent); }
.breadcrumb .sep { margin: 0 6px; color: #ccc; }

/* ------ 按钮 ------ */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border-radius: 8px;
    border: none;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    line-height: 1.4;
}
.btn-primary {
    background: linear-gradient(135deg, var(--color-accent), var(--color-primary-light));
    color: #fff;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 15px rgba(15,52,96,0.3); }
.btn-secondary {
    background: #fff;
    color: var(--color-text);
    border: 1px solid var(--color-border);
}
.btn-secondary:hover {
    background: #f8f9fa;
    border-color: #ccc;
}
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-danger { background: var(--color-error); color: #fff; }
.btn-danger:hover { background: #c0392b; }
.btn-small {
    display: inline-block;
    padding: 4px 10px;
    font-size: 12px;
    border-radius: 4px;
    background: #f0f0f0;
    color: var(--color-text);
    text-decoration: none;
    margin: 0 2px;
}
.btn-small.btn-danger { background: #fee; color: var(--color-error); }
.btn-small:hover { opacity: 0.8; }

/* ------ 卡片 ------ */
.card {
    background: var(--color-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 24px;
    overflow: hidden;
}
.card-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.card-header h3 { font-size: 16px; font-weight: 600; }
.card-body { padding: 24px; }

/* ------ 表格 ------ */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
.data-table th {
    background: #f8f9fa;
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    color: var(--color-text-light);
    border-bottom: 2px solid var(--color-border);
    white-space: nowrap;
}
.data-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--color-border);
}
.data-table tbody tr:hover { background: #f8f9fa; }
.table-info { margin-bottom: 12px; font-size: 13px; color: var(--color-text-light); }

/* ------ 表单 ------ */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 4px; font-size: 14px; font-weight: 500; color: var(--color-text); }
.form-group input[type="text"],
.form-group input[type="password"],
.form-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s;
}
.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(15,52,96,0.1);
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.narrow-form { max-width: 500px; }
.checkbox-group { display: flex; gap: 16px; flex-wrap: wrap; }
.checkbox-group label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-weight: normal;
    cursor: pointer;
    font-size: 13px;
}
.required { color: var(--color-error); }
.inline-form { display: flex; gap: 8px; align-items: center; }
.inline-form input[type="text"] {
    padding: 6px 12px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 13px;
}

/* ------ 提示信息 ------ */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
.alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.alert-error { background: #fef2f2; color: var(--color-error); border: 1px solid #fecaca; }
.alert-info { background: #d1ecf1; color: #0c5460; border: 1px solid #bee5eb; }

/* ------ 徽章 ------ */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 500;
    background: #e1e4e8;
    color: var(--color-text);
}
.badge-admin { background: #e8f0fe; color: #1a73e8; }
.badge-normal { background: #e8f5e9; color: #2e7d32; }
.badge-locked { background: #fef2f2; color: var(--color-error); }
.badge-active { background: #e8f5e9; color: var(--color-success); }

/* ------ 分页 ------ */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 20px;
}
.page-nums { display: flex; gap: 4px; align-items: center; }
.page-nums a {
    padding: 6px 12px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 13px;
    color: var(--color-text);
    text-decoration: none;
}
.page-nums a.current { background: var(--color-accent); color: #fff; border-color: var(--color-accent); }
.page-nums a:hover:not(.current) { background: #f0f0f0; }

/* ------ 空状态 ------ */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--color-text-light);
}
.empty-state p { font-size: 16px; margin-bottom: 8px; }

/* ------ 管理页面容器 ------ */
.admin-container { padding: 24px; }

/* ------ 搜索页 ------ */
.search-container { padding: 24px; }
.search-card {
    margin: 0 auto;
    background: var(--color-card);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    margin-bottom: 24px;
    max-width: 600px;
}
.search-form .search-row {
    display: flex;
    gap: 12px;
    align-items: center;
}
.search-field-select {
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    font-size: 14px;
    background: #fff;
}
.search-input {
    flex: 1;
    padding: 10px 16px;
    border: 2px solid var(--color-border);
    border-radius: 8px;
    font-size: 15px;
    transition: border-color 0.2s;
}
.search-input:focus { outline: none; border-color: var(--color-accent); }
.search-results { margin-top: 20px; }
.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    font-size: 14px;
    color: var(--color-text-light);
}
.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 12px;
}
.result-card {
    display: block;
    background: #ffffff;
    border: 1.5px solid #d4b8a0;
    border-radius: 8px;
    padding: 16px;
    text-decoration: none;
    color: #5a4a3a;
    transition: all 0.25s ease;
    position: relative;
}
.result-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 3px 12px rgba(184,131,90,0.15);
    border-color: #b8835a;
    background: #fdf8f4;
    z-index: 100;
}
.result-card.is-deceased {
    background: #ece4d9;
    border-color: #bfa88a;
}
.result-card.is-deceased:hover {
    background: #e2d6c6;
    border-color: #b8835a;
}
.result-name { font-size: 18px; font-weight: 600; margin-bottom: 4px; color: #5a3e2b; }
.result-name2 { font-size: 13px; color: #8a7a6a; margin-bottom: 8px; }
.result-meta { display: flex; gap: 12px; font-size: 12px; color: #8a7a6a; }

.grid-filler {
    display: block;
    height: 0;
    padding: 0;
    border: none;
    visibility: hidden;
    pointer-events: none;
}

/* 搜索结果浮窗提示 */
.search-tip {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: #5a3e2b;
    color: #fff;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.6;
    white-space: normal;
    width: max-content;
    max-width: 360px;
    z-index: 20;
    box-shadow: 0 4px 16px rgba(0,0,0,0.25);
    pointer-events: none;
}
.search-tip::after {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-bottom-color: #5a3e2b;
}
.result-card:hover .search-tip {
    display: block;
}

/* ------ 成员详情页 ------ */
.member-detail-container { padding: 24px; }
.member-detail-card {
    background: var(--color-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.member-detail-grid { padding: 24px; }
.detail-section { margin-bottom: 28px; }
.section-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--color-primary);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--color-gold);
}
.detail-table { width: 100%; border-collapse: collapse; }
.detail-table td {
    padding: 8px 12px;
    font-size: 14px;
    border-bottom: 1px solid #f0f0f0;
}
.detail-table .label {
    width: 100px;
    font-weight: 500;
    color: var(--color-text-light);
    background: #fafafa;
}
.detail-table .value { color: var(--color-text); }
.spouse-role {
    font-size: 12px;
    color: #999;
}
.child-role {
    font-size: 12px;
    color: #999;
}
.text-content {
    font-size: 14px;
    line-height: 1.8;
    color: var(--color-text);
    padding: 8px 0;
}
.child-link {
    display: inline-block;
    margin: 2px 4px;
    padding: 4px 10px;
    background: #f0f7ff;
    border-radius: 4px;
    font-size: 13px;
}
.no-data { color: var(--color-text-light); font-size: 13px; }
.detail-actions {
    padding: 16px 24px;
    background: #f8f9fa;
    border-top: 1px solid var(--color-border);
    display: flex;
    gap: 12px;
}

/* ------ 家谱树控制栏 ------ */
.tree-controls {
    background: var(--color-card);
    border-bottom: 1px solid var(--color-border);
    padding: 12px 24px;
    position: sticky;
    top: 60px;
    z-index: 50;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
.tree-controls-inner {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 12px;
}
.tree-controls select {
    padding: 6px 12px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 13px;
}
.tree-search-box {
    margin-left: auto;
    display: flex;
    gap: 4px;
}
.tree-search-box input {
    padding: 6px 12px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 13px;
    width: 180px;
}
.tree-search-box button {
    padding: 6px 12px;
    border: none;
    border-radius: 6px;
    background: var(--color-accent);
    color: #fff;
    cursor: pointer;
}
.tree-stats {
    display: flex;
    gap: 20px;
    font-size: 13px;
    color: var(--color-text-light);
}
.tree-stats strong { color: var(--color-accent); }

/* ====== 汉堡菜单按钮 ====== */
.hamburger {
    display: none;
    flex-direction: column;
    justify-content: space-around;
    width: 28px;
    height: 24px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 1100;
}
.hamburger span {
    display: block;
    width: 100%;
    height: 3px;
    background: #f5e6d3;
    border-radius: 3px;
    transition: all 0.3s ease;
}
.hamburger.open span:nth-child(1) { transform: translateY(9px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: translateY(-9px) rotate(-45deg); }

/* ------ 移动端响应式 ------ */

/* 平板：768px 以下 */
@media (max-width: 768px) {
    .hamburger { display: flex; }
    .header-inner { height: auto; padding: 10px 16px; }
    .main-nav {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        background: rgba(42, 30, 20, 0.97);
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 18px;
        z-index: 1000;
    }
    .main-nav.open { display: flex; }
    .main-nav a {
        font-size: 20px;
        color: #f5e6d3;
        padding: 10px 20px;
        border-bottom: 1px solid rgba(245,230,211,0.15);
        width: auto;
        min-width: 160px;
        text-align: center;
    }
    .main-nav a:hover { color: #f5e6d3; background: rgba(245,230,211,0.1); border-radius: 6px; }
    .main-nav .user-info {
        font-size: 14px;
        color: #b8a898;
        margin-top: 10px;
        border-bottom: none;
    }
    .nav-admin-trigger { display: flex; flex-direction: column; align-items: center; width: 100%; }
    .nav-admin-dropdown {
        position: static;
        display: none;
        background: rgba(255,255,255,0.08);
        border: 1px solid rgba(245,230,211,0.2);
        box-shadow: none;
        min-width: 100%;
        margin-top: 4px;
        border-radius: 8px;
    }
    .nav-admin-dropdown a { color: #d4c4b0 !important; text-align: center; font-size: 16px; }
    .nav-admin-dropdown a:hover { background: rgba(255,255,255,0.1) !important; color: #fff !important; }
    .dropdown-divider { background: rgba(245,230,211,0.15); }

    .search-form .search-row { flex-direction: column; align-items: stretch; gap: 8px; }
    .search-row .search-bracket { text-align: center; }
    .search-row select, .search-row input[type="text"] { width: 100%; }
    .results-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .form-grid { grid-template-columns: 1fr; }
    .tree-controls-inner { flex-wrap: wrap; justify-content: center; }
    .tree-search-box { margin-left: 0; width: 100%; }
    .tree-search-box input { flex: 1; min-width: 0; }
    .page-header-inner { flex-direction: column; gap: 8px; align-items: flex-start; }

    /* 管理员表格自适应 */
    .data-table { font-size: 13px; }
    .data-table th, .data-table td { padding: 6px 4px; }

    /* 弹窗移动端适配 */
    #memberModal > div { width: 92% !important; height: 80vh !important; }

    /* member 详情页 */
    .member-detail-grid { padding: 12px; }
    .detail-table td.label { width: 70px; font-size: 13px; }
    .detail-table td.value { font-size: 14px; }

    /* 数据库页面 */
    .database-scroll-area { max-height: none !important; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .database-table { font-size: 12px; }
    .pagination-bar { flex-direction: column; gap: 8px; align-items: center; }
    .pagination-links { flex-wrap: wrap; justify-content: center; }

    /* 统计页面 */
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .stat-card { padding: 14px; }
    .stat-card .stat-number { font-size: 24px; }

    /* 查无此人页面 */
    .admin-container { padding: 12px; }
    .card-body { padding: 14px; }

    /* 搜索提示 tooltip 移动端 */
    .result-card .search-tip { position: static; opacity: 1; visibility: visible; box-shadow: none; border-top: 1px solid #f0e6dc; margin-top: 6px; padding-top: 6px; background: transparent; }
}

/* 手机：480px 以下 */
@media (max-width: 480px) {
    .results-grid { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
    .stat-card { padding: 12px; }
    .stat-card .stat-number { font-size: 20px; }

    .page-header-inner h2 { font-size: 18px; }

    .detail-table td.label { width: 60px; font-size: 12px; }
    .detail-table td.value { font-size: 13px; }

    .database-table { font-size: 11px; }
    .database-table th, .database-table td { padding: 4px 3px; }

    .pagination-text { font-size: 12px; }
    .pagination-links a { font-size: 12px; padding: 4px 8px; }

    .card-header { flex-direction: column; gap: 8px; align-items: flex-start; }
    .card-header .badge { align-self: flex-start; }

    .main-nav a { font-size: 18px; min-width: 140px; }

    /* tree page */
    .tree-controls { padding: 8px; }
    .tree-controls-inner { gap: 6px; }
    .tree-controls-inner button { font-size: 12px; padding: 4px 8px; }

    .search-bracket { font-size: 14px; }
    .detail-actions { flex-direction: column; gap: 8px; }
    .detail-actions .btn { width: 100%; text-align: center; }

    /* breadcrumb wrap */
    .breadcrumb { font-size: 12px; white-space: normal; line-height: 1.8; }

    .hbar-label { width: 60px; font-size: 11px; }
    .chart-section { padding: 12px; }
    .chart-section h3 { font-size: 15px; }
}

/* 超小屏：360px 以下 */
@media (max-width: 360px) {
    .stats-grid { grid-template-columns: 1fr; }
    .results-grid { grid-template-columns: 1fr; }
    .main-nav a { font-size: 16px; min-width: 120px; }
}

/* ============================================================
   回到顶部按钮
   ============================================================ */
.back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--color-accent), var(--color-primary-light));
    color: #fff;
    border: none;
    font-size: 20px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    line-height: 1;
}
.back-to-top:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}
.back-to-top.visible {
    display: flex;
}

@media (max-width: 768px) {
    .back-to-top {
        bottom: 16px;
        right: 16px;
        width: 38px;
        height: 38px;
        font-size: 16px;
    }
}

/* 访客模式提示条 */
.guest-notice {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(90,62,43,0.92);
    color: #f5e6d3;
    text-align: center;
    padding: 6px 16px;
    font-size: 13px;
    z-index: 9997;
    backdrop-filter: blur(4px);
}

/* 搜索结果受限制卡片 */
.result-card.guest-restricted {
    opacity: 0.75;
}
.result-card.guest-restricted .result-name {
    color: #8a7a6a;
}

