/* ============================================
   村务信息查询系统 - 全局样式
   ============================================ */

/* CSS变量 */
:root {
    --primary-color: #1a73e8;
    --primary-hover: #1557b0;
    --primary-light: #e8f0fe;
    --success-color: #34a853;
    --warning-color: #fbbc04;
    --danger-color: #ea4335;
    --text-color: #202124;
    --text-secondary: #5f6368;
    --border-color: #dadce0;
    --bg-color: #f8f9fa;
    --white: #ffffff;
    --shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 6px rgba(0,0,0,0.1), 0 2px 4px rgba(0,0,0,0.06);
    --radius: 8px;
    --radius-sm: 4px;
}

/* 重置 */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
    background-color: var(--bg-color); color: var(--text-color); line-height: 1.6; min-height: 100vh;
}

/* 容器 */
.container { max-width: 1400px; margin: 0 auto; padding: 20px; }

/* ============================================
   筛选区
   ============================================ */
.filter-section {
    background: var(--white); border-radius: var(--radius); padding: 20px;
    margin-bottom: 20px; box-shadow: var(--shadow);
}
.filter-title {
    font-size: 14px; font-weight: 600; color: var(--text-secondary);
    margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border-color);
    display: flex; align-items: center; justify-content: space-between;
}
.filter-toggle {
    background: none; border: 1px solid var(--border-color); border-radius: var(--radius-sm);
    cursor: pointer; padding: 2px 8px; font-size: 12px; color: var(--text-secondary);
    transition: all 0.2s; display: inline-flex; align-items: center;
}
.filter-toggle:hover { background: var(--primary-light); border-color: var(--primary-color); color: var(--primary-color); }
.toggle-icon { transition: transform 0.3s; display: inline-block; }
.filter-body { overflow: hidden; transition: max-height 0.3s ease, opacity 0.3s ease; }
.filter-body.collapsed { max-height: 0 !important; opacity: 0; margin: 0; padding: 0; }
.filter-group { margin-bottom: 16px; }
.filter-group:first-child {
    background: linear-gradient(135deg, #f0f4ff 0%, #e8f0fe 100%);
    padding: 16px; border-radius: var(--radius); border: 1px solid #d2e0fc;
}
.filter-row { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 12px; }
.filter-item-search { flex: 1 1 100% !important; min-width: 0; }
.filter-item-search input[type="text"] {
    flex: 1; min-width: 0; width: 100%;
    padding: 12px 16px; font-size: 15px; border: 2px solid var(--border-color); border-radius: var(--radius);
    background: #f0f4ff; transition: border-color 0.2s, box-shadow 0.2s;
}
.filter-item-search input[type="text"]:focus {
    border-color: var(--primary-color); background: var(--white);
    box-shadow: 0 0 0 3px rgba(26,115,232,0.25);
}
.filter-item-search input[type="text"]::placeholder { color: #888; font-size: 14px; }
.filter-item { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.filter-item label {
    font-size: 13px; font-weight: 500; color: var(--text-secondary);
    white-space: nowrap; min-width: 60px;
}
.filter-item input[type="text"], .filter-item select {
    padding: 8px 12px; border: 1px solid var(--border-color); border-radius: var(--radius-sm);
    font-size: 13px; color: var(--text-color); background: var(--white);
    transition: border-color 0.2s, box-shadow 0.2s; min-width: 160px;
}
.filter-item input[type="text"]:focus, .filter-item select:focus {
    outline: none; border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(26,115,232,0.2);
}

/* 按钮组 */
.filter-buttons {
    display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px;
    padding-top: 16px; border-top: 1px solid var(--border-color);
}
.btn {
    display: inline-flex; align-items: center; gap: 6px; padding: 8px 20px;
    border: none; border-radius: var(--radius-sm); font-size: 13px;
    font-weight: 500; cursor: pointer; transition: all 0.2s;
}
.btn-primary { background: var(--primary-color); color: var(--white); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--bg-color); color: var(--text-color); border: 1px solid var(--border-color); }
.btn-secondary:hover { background: #e8eaed; }
.btn-success { background: var(--success-color); color: var(--white); }
.btn-success:hover { background: #2d9249; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-sm { padding: 5px 12px; font-size: 12px; }

/* ============================================
   多选下拉组件
   ============================================ */
.multi-select { position: relative; min-width: 160px; }
.multi-select .ms-trigger {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 12px; border: 1px solid var(--border-color); border-radius: var(--radius-sm);
    font-size: 13px; color: var(--text-color); background: var(--white);
    cursor: pointer; transition: border-color 0.2s, box-shadow 0.2s; user-select: none;
    min-width: 160px; max-width: 220px;
}
.multi-select .ms-trigger:hover, .multi-select.open .ms-trigger {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(26,115,232,0.2);
}
.multi-select .ms-trigger .ms-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.multi-select .ms-trigger .ms-arrow { margin-left: 6px; font-size: 10px; transition: transform 0.2s; }
.multi-select.open .ms-trigger .ms-arrow { transform: rotate(180deg); }
.multi-select .ms-dropdown {
    display: none; position: absolute; top: 100%; left: 0; right: 0; z-index: 100;
    background: var(--white); border: 1px solid var(--border-color); border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg); max-height: 240px; overflow-y: auto; margin-top: 2px;
}
.multi-select.open .ms-dropdown { display: block; }
.multi-select .ms-option {
    display: flex; align-items: center; gap: 8px; padding: 7px 12px;
    font-size: 13px; cursor: pointer; transition: background 0.15s;
}
.multi-select .ms-option:hover { background: var(--primary-light); }
.multi-select .ms-option input[type="checkbox"] { margin: 0; cursor: pointer; accent-color: var(--primary-color); }
.multi-select.disabled { opacity: 0.5; pointer-events: none; }
.multi-select .ms-option.ms-all {
    border-bottom: 1px solid var(--border-color); font-weight: 600;
    background: #f8f9fa; position: sticky; top: 0; z-index: 1;
}

/* ============================================
   底部导出栏
   ============================================ */
.export-bar {
    display: flex; justify-content: center; gap: 12px; padding: 16px 20px;
    border-top: 1px solid var(--border-color); background: var(--white);
}

/* ============================================
   数据表格区
   ============================================ */
.table-section {
    background: var(--white); border-radius: var(--radius);
    box-shadow: var(--shadow); overflow: hidden;
}
.table-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 16px 20px; border-bottom: 1px solid var(--border-color);
}
.table-header h3 { font-size: 15px; font-weight: 600; }
.table-header .result-info { font-size: 13px; color: var(--text-secondary); }
.table-wrapper { overflow-x: auto; max-height: 600px; overflow-y: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table thead { position: sticky; top: 0; z-index: 10; }
.data-table th {
    background: #f1f3f4; padding: 12px 16px; text-align: left;
    font-weight: 600; color: var(--text-secondary); border-bottom: 2px solid var(--border-color);
    white-space: nowrap; user-select: none;
}
.data-table td {
    padding: 10px 16px; border-bottom: 1px solid #f0f0f0; color: var(--text-color);
    max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.data-table tbody tr:hover { background: var(--primary-light); }
.data-table tbody tr:nth-child(even) { background: #fafbfc; }
.data-table tbody tr:nth-child(even):hover { background: var(--primary-light); }
.data-table tbody tr.row-head { background: #fff3e0; font-weight: 600; }
.data-table tbody tr.row-head:nth-child(even) { background: #ffe8cc; }
.data-table tbody tr.row-head:hover { background: #ffd699; }

/* 空状态 */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-secondary); }
.empty-state .empty-icon { font-size: 48px; margin-bottom: 16px; opacity: 0.5; }

/* ============================================
   分页
   ============================================ */
.pagination {
    display: flex; justify-content: space-between; align-items: center;
    padding: 16px 20px; border-top: 1px solid var(--border-color); flex-wrap: wrap; gap: 12px;
}
.pagination .page-info { font-size: 13px; color: var(--text-secondary); }
.pagination .page-controls { display: flex; align-items: center; gap: 4px; }
.pagination .page-btn {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 36px; height: 36px; padding: 0 8px; border: 1px solid var(--border-color);
    border-radius: var(--radius-sm); background: var(--white); color: var(--text-color);
    font-size: 13px; cursor: pointer; transition: all 0.2s;
}
.pagination .page-btn:hover:not(:disabled) {
    background: var(--primary-light); border-color: var(--primary-color); color: var(--primary-color);
}
.pagination .page-btn.active {
    background: var(--primary-color); border-color: var(--primary-color); color: var(--white);
}
.pagination .page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ============================================
   提示信息
   ============================================ */
.toast {
    position: fixed; top: 20px; right: 20px; padding: 12px 24px;
    background: var(--text-color); color: var(--white); border-radius: var(--radius-sm);
    font-size: 14px; z-index: 1000; opacity: 0; transform: translateY(-10px);
    transition: all 0.3s; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { background: var(--success-color); }
.toast.error { background: var(--danger-color); }

/* ============================================
   登录遮罩层
   ============================================ */
.login-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex; align-items: center; justify-content: center; z-index: 9999;
}
.login-box {
    background: var(--white); border-radius: 12px; padding: 40px 36px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3); width: 380px; max-width: 90vw;
    text-align: center;
}
.login-box .login-icon { font-size: 48px; margin-bottom: 12px; }
.login-box h2 { font-size: 20px; color: var(--text-color); margin-bottom: 6px; }
.login-box p { font-size: 13px; color: var(--text-secondary); margin-bottom: 24px; }
.login-box input[type="password"] {
    width: 100%; padding: 12px 16px; border: 2px solid var(--border-color);
    border-radius: var(--radius); font-size: 15px; text-align: center;
    outline: none; transition: border-color 0.2s;
}
.login-box input[type="password"]:focus { border-color: var(--primary-color); }
.login-box .login-btn {
    width: 100%; padding: 12px; margin-top: 16px; background: var(--primary-color);
    color: var(--white); border: none; border-radius: var(--radius); font-size: 15px;
    font-weight: 600; cursor: pointer; transition: background 0.2s;
}
.login-box .login-btn:hover { background: var(--primary-hover); }
.login-box .login-error {
    margin-top: 12px; font-size: 13px; color: var(--danger-color);
    min-height: 20px;
}
.login-box .login-hint {
    margin-top: 20px; font-size: 11px; color: #aaa;
}

/* 主内容区域 */
.main-content { display: none; }
.main-content.unlocked { display: block; }

/* ============================================
   响应式
   ============================================ */
@media (max-width: 768px) {
    .container { padding: 12px; }
    .filter-item { flex: 1 1 100%; }
    .filter-item input[type="text"], .filter-item select { min-width: 0; flex: 1; width: 100%; }
    .filter-item-search { flex: 1 1 100%; }
    .filter-item-search input[type="text"] { font-size: 14px; padding: 10px 14px; }
    .multi-select { min-width: 0; width: 100%; }
    .multi-select .ms-trigger { min-width: 0; max-width: none; width: 100%; }
    .filter-buttons { flex-direction: column; }
    .filter-buttons .btn { width: 100%; justify-content: center; }
    .login-box { padding: 28px 24px; }
    .table-wrapper { max-height: 70vh; }
    .data-table td, .data-table th { padding: 8px 10px; font-size: 12px; }
}
