/* ===== 全局样式 ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Microsoft YaHei', 'PingFang SC', sans-serif;
}

body {
    background-color: #f5f7fa;
    color: #333;
    line-height: 1.4;
    font-size: 14px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 10px;
}

/* ===== 头部样式 ===== */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #556B2F;
}

h1 {
    color: #556B2F;
    font-size: 24px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.controls-row-1 {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.controls-row-2 {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: flex-start;
    padding-top: 5px;
    border-top: 1px solid #e0e0e0;
}

.search-box {
    display: flex;
    flex: 1;
    max-width: 300px;
}

#search-input {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px 0 0 4px;
    width: 100%;
    font-size: 14px;
}

#search-btn {
    padding: 8px 15px;
    background: #556B2F;
    color: white;
    border: none;
    border-radius: 0 4px 4px 0;
    cursor: pointer;
    transition: background 0.3s;
}

#search-btn:hover {
    background: #732d91;
}

#edit-mode-btn {
    padding: 8px 15px;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    transition: background 0.3s;
    display: flex;
    align-items: center;
    gap: 8px;
}

#edit-mode-btn:hover {
    background: #2980b9;
}

#exit-edit-btn {
    padding: 8px 15px;
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    transition: background 0.3s;
    display: flex;
    align-items: center;
    gap: 8px;
}

#exit-edit-btn:hover {
    background: #c0392b;
}

/* ===== 密码模态框样式 ===== */
.password-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.password-modal .modal-content {
    background: white;
    border-radius: 10px;
    width: 380px;
    max-width: 90%;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

.modal-header {
    background: #2ecc71;
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-badge {
    background: rgba(255, 255, 255, 0.2);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
}

.modal-body {
    padding: 20px;
}

.password-input-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}

.password-input-row input {
    flex: 1;
    padding: 10px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.3s;
    background: #f8f9fa;
}

.password-input-row input:focus {
    border-color: #2ecc71;
    outline: none;
    background: white;
}

.password-buttons {
    display: flex;
    gap: 8px;
}

.password-buttons button {
    padding: 10px 10px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: all 0.3s;
    white-space: nowrap;
    min-width: 60px;
}

#cancel-btn {
    background: #e74c3c;
    color: white;
}

#cancel-btn:hover {
    background: #c0392b;
    transform: translateY(-1px);
}

#confirm-btn {
    background: #2ecc71;
    color: white;
}

#confirm-btn:hover {
    background: #27ae60;
    transform: translateY(-1px);
}

.person-preview {
    border-top: 1px solid #f0f0f0;
    padding-top: 15px;
    margin-top: 15px;
}

.preview-card {
    background: #f8f9fa;
    border-radius: 6px;
    padding: 12px;
    border-left: 3px solid #2ecc71;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.preview-header strong {
    font-size: 16px;
    color: #2c3e50;
    font-weight: bold;
}

.preview-header span {
    font-size: 12px;
    color: #7f8c8d;
}

.preview-dates {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.preview-dates span {
    font-size: 12px;
    color: #95a5a6;
}

/* ===== 家谱树样式 ===== */
.tree-container {
    background: white;
    border-radius: 8px;
    padding: 5px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin-top: 20px;
}

.tree-node {
    margin: 0;
    padding: 0;
}

.tree-item {
    display: flex;
    align-items: center;
    padding: 5px 2px;
    border-bottom: 1px solid #f0f0f0;
    transition: background-color 0.2s;
}

.tree-item:hover {
    background-color: #f9f9f9;
}

.tree-toggle {
    width: 30px;
    text-align: center;
    cursor: pointer;
    color: #7a7202;
    margin-right: 6px;
    font-size: 30px;
}

.tree-toggle.has-children:hover {
    color: #556B2F;
}

.tree-toggle.no-children {
    color: #ccc;
    cursor: default;
}

.tree-icon {
    width: 24px;
    text-align: center;
    color: #f39c12;
    margin-right: 8px;
}

.tree-icon .fa-user {
    color: #3498db;
}

.tree-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.person-name-wrapper {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 3px;
}

.person-name-container {
    display: flex;
    align-items: flex-end;
    flex-wrap: wrap;
}

.person-name {
    font-weight: bold;
    font-size: 18px;
    color: #2c3e50;
    line-height: 1;
    margin-left: 5px;
}

.generation-badge {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #D6E0F0;
    color: #34495E;
    font-size: 9px;
    font-weight: bold;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    margin-left: 8px;
    margin-bottom: -2px;
}

.generation-yz {
        width: 24px;
    height: 36px;
    border-radius: 50%;
    background: #D6E0F0;
    color: #8B0000;
    font-size: 14px;
    font-weight: bold;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    margin-left: 0px;
    margin-bottom: -1px;
}

.generation-relation {
   width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #E0F2F1;
    color: #0f2b46;
    font-size: 10px;
    font-weight: bold;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    margin-left: 12px;
    margin-bottom: -2px;
}

.spouse-info {
    font-size: 14px;
    color: #7f8c8d;
    margin-left: 8px;   
    white-space: nowrap;
    line-height: 1;
    margin-bottom: 0px;
}

.person-info {
    font-size: 14px;
    color: #7f8c8d;
    margin-bottom: 3px;
    font-weight: initial;
       margin-left: 27px;
}

.person-dates {
    font-size: 14px;
    color: #95a5a6;
    margin-left: 30px;
}

.person-spouse {
    font-size: 14px;
    color: #95a5a6;
    margin-left: 22px;
}
.tree-actions {
    display: flex;
    gap: 6px;
    opacity: 0;
    transition: opacity 0.2s;
}

.tree-item:hover .tree-actions {
    opacity: 1;
}

.action-btn {
    padding: 5px 8px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
}

.view-btn {
    background: #3498db;
    color: white;
}

.edit-btn {
    background: #f39c12;
    color: white;
}

.add-child-btn {
    background: #2ecc71;
    color: white;
}

.delete-btn {
    background: #e74c3c;
    color: white;
}

.tree-children {
    margin-left: 10px;
    border-left: 1px dashed #ddd;
    display: none;
}

/* ===== 编辑页面样式 ===== */
.form-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #556B2F;
}

.form-header h1 {
    color: #556B2F;
    font-size: 22px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: #3498db;
    font-weight: bold;
    font-size: 15px;
    padding: 8px 15px;
    border: 1px solid #3498db;
    border-radius: 6px;
    transition: all 0.3s;
}

.back-btn:hover {
    background: #3498db;
    color: white;
}

.person-form {
    background: white;
    border-radius: 10px;
    padding: 25px;
    box-shadow: 0 3px 15px rgba(0, 0, 0, 0.1);
    max-width: 900px;
    margin: 0 auto;
}

.form-tabs {
    display: flex;
    border-bottom: 1px solid #e0e0e0;
    margin-bottom: 25px;
}

.tab {
    padding: 12px 25px;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.3s;
    font-weight: bold;
    color: #7f8c8d;
    font-size: 15px;
}

.tab.active {
    color: #556B2F;
    border-bottom-color: #556B2F;
}

.tab:hover {
    color: #556B2F;
}

.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
}

.form-section {
    margin-bottom: 25px;
    padding: 20px;
    border-radius: 8px;
    background: #f8f9fa;
    border-left: 4px solid #556B2F;
}

.form-section h2 {
    color: #556B2F;
    margin-bottom: 18px;
    font-size: 18px;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ===== 关键修改：确保表单组在同一行显示 ===== */
.form-group {
    display: flex;
    align-items: center;
    margin-bottom: 15px;
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f0;
}

.form-group:last-child {
    border-bottom: none;
}

.form-group label {
    width: 120px;
    font-weight: bold;
    color: #2c3e50;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 5px;
    flex-shrink: 0;
    margin-bottom: 0;
}

.required {
    color: #e74c3c;
}

.form-group input,
.form-group select,
.form-group textarea {
    flex: 1;
    padding: 10px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.3s;
    min-height: 40px;
    margin-bottom: 0;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: #556B2F;
    outline: none;
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

input[placeholder*=":"], input[placeholder*="时间"] {
    font-family: 'Courier New', monospace;
    letter-spacing: 1px;
}

/* 特殊处理复选框和文本区域 */
.checkbox-group {
    flex-direction: row;
    align-items: center;
    margin-top: 10px;
    border-bottom: none;
}

.checkbox-group label {
    width: auto;
    font-weight: normal;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
}

.checkbox-group input[type="checkbox"] {
    display: none;
}

.checkmark {
    width: 20px;
    height: 20px;
    border: 2px solid #bdc3c7;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.checkbox-group input[type="checkbox"]:checked + .checkmark {
    background: #556B2F;
    border-color: #556B2F;
}

.checkbox-group input[type="checkbox"]:checked + .checkmark::after {
    content: '✓';
    color: white;
    font-size: 14px;
}

/* 文件上传样式 */
.file-upload {
    display: flex;
    align-items: center;
}

.file-upload input[type="file"] {
    padding: 8px;
    background: #f8f9fa;
    border: 2px dashed #ddd;
    border-radius: 6px;
}

.photo-preview {
    margin-top: 15px;
}

.photo-preview p {
    font-weight: bold;
    margin-bottom: 10px;
    color: #2c3e50;
    font-size: 14px;
}

.photo-preview img {
    max-width: 180px;
    max-height: 180px;
    border-radius: 8px;
    border: 2px solid #e0e0e0;
}

.form-buttons {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #e0e0f0;
}

.save-btn, .cancel-btn {
    padding: 12px 30px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s;
}

.save-btn {
    background: #2ecc71;
    color: white;
}

.save-btn:hover {
    background: #27ae60;
    transform: translateY(-2px);
}

.cancel-btn {
    background: #95a5a6;
    color: white;
    text-decoration: none;
}

.cancel-btn:hover {
    background: #7f8c8d;
    transform: translateY(-2px);
}

/* ===== 响应式设计 ===== */
@media (max-width: 768px) {
    header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .controls {
        width: 100%;
    }

    .search-box {
        width: 100%;
        max-width: none;
    }

    .form-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .person-form {
        padding: 20px;
    }

    /* 在移动设备上，表单组保持水平布局 */
    .form-group {
        flex-direction: row;
        align-items: center;
    }

    .form-group label {
        width: 100px;
        margin-bottom: 0;
    }

    .form-group input,
    .form-group select,
    .form-group textarea {
        width: auto;
    }

    .form-tabs {
        flex-wrap: wrap;
    }

    .tab {
        flex: 1;
        text-align: center;
        padding: 10px 15px;
    }

    .form-buttons {
        flex-direction: column;
    }

    .save-btn, .cancel-btn {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .form-section {
        padding: 15px;
    }

    .form-group {
        margin-bottom: 12px;
        padding: 6px 0;
    }

    .form-group label {
        width: 90px;
        font-size: 13px;
    }

    .form-group input,
    .form-group select,
    .form-group textarea {
        padding: 8px 10px;
        font-size: 13px;
        min-height: 36px;
    }

    .form-group textarea {
        min-height: 80px;
    }

    .photo-preview img {
        max-width: 120px;
        max-height: 120px;
    }

    /* 在非常小的屏幕上，表单组才换行 */
    @media (max-width: 360px) {
        .form-group {
            flex-direction: column;
            align-items: flex-start;
            gap: 8px;
        }

        .form-group label {
            width: 100%;
            margin-bottom: 5px;
        }

        .form-group input,
        .form-group select,
        .form-group textarea {
            width: 100%;
        }
    }
}


.navigation-buttons {
    display: flex;
    justify-content: space-between;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #e0e0e0;
}

.nav-btn {
    padding: 10px 15px;
    border: 1px solid #3498db;
    border-radius: 6px;
    color: #3498db;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s;
}

.nav-btn:hover {
    background: #3498db;
    color: white;
}


/* 导入导出按钮样式 */
.import-btn, .export-btn {
    padding: 8px 15px;
    border: none;
    border-radius: 4px;
    text-decoration: none;
    color: white;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s;
}

.import-btn {
    background: #27ae60;
}

.import-btn:hover {
    background: #219653;
}

.export-btn {
    background: #3498db;
}

.export-btn:hover {
    background: #2980b9;
}

#logout-btn {
    padding: 8px 15px;
    background: #95a5a6;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    transition: background 0.3s;
    display: flex;
    align-items: center;
    gap: 8px;
}

#logout-btn:hover {
    background: #c0392b;
}

/*搜索按钮*/
.highlight-searched {
    background-color: #fff3cd !important;
    border: 2px solid #ffc107 !important;
    border-radius: 5px;
    transition: all 0.3s ease;
}


/* 图标说明区域样式 - 一行两个布局 */
.icon-legend {
    margin: 20px auto;
    padding: 15px;
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    max-width: 500px;
}

.legend-title {
    font-weight: bold;
    margin-bottom: 15px;
    color: #495057;
    font-size: 12px;
    text-align: center;
}

.legend-items {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.legend-row {
    display: flex;
    justify-content: space-between;
    width: 100%; /* 确保行占满整个宽度 */
}

.legend-item {
    display: flex;
    align-items: center;
    flex: 1; /* 每个项目平均分配空间 */
    margin: 0 10px;
    min-height: 30px;
}

.legend-icon {
    width: 20px;
    text-align: left;
    margin-right: 2px;
    font-size: 16px;
}

.legend-text {
    font-size: 12px;
    color: #495057;
}
