/**
 * 房产协会管理系统 - 诺依风格主题
 * 深色侧边栏 + 现代卡片布局 + 简洁配色 + 多页签
 * 纯CSS实现，不依赖Vue等前端框架
 */

/* ========== 全局变量 ========== */
:root {
    --primary-color: #409eff;
    --primary-light: #66b1ff;
    --primary-dark: #3a8ee6;
    --success-color: #67c23a;
    --warning-color: #e6a23c;
    --danger-color: #f56c6c;
    --info-color: #909399;

    --sidebar-bg: #fff;
    --sidebar-dark: #f5f7fa;
    --sidebar-text: #4a4a4a;
    --sidebar-text-active: #409eff;
    --sidebar-hover: #ecf5ff;

    --topbar-bg: #fff;
    --topbar-height: 50px;
    --topbar-shadow: 0 1px 4px rgba(0,21,41,.08);

    --body-bg: #f0f2f5;
    --card-bg: #fff;
    --card-shadow: 0 2px 12px 0 rgba(0,0,0,.05);
    --card-radius: 4px;

    --text-primary: #303133;
    --text-regular: #606266;
    --text-secondary: #909399;
    --text-placeholder: #c0c4cc;
    --border-color: #dcdfe6;
    --border-light: #e4e7ed;

    --sidebar-width: 210px;
    --sidebar-collapsed-width: 64px;
    --transition-time: .28s;
}

/* ========== 基础重置 ========== */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; font-size: 14px; color: var(--text-primary); background: var(--body-bg); }
a { color: var(--primary-color); text-decoration: none; }
a:hover { color: var(--primary-light); }

/* ========== 滚动条美化 ========== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: #c0c4cc; border-radius: 3px; }
::-webkit-scrollbar-track { background: transparent; }

/* ========== 侧边栏 ========== */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    position: fixed;
    left: 0;
    top: 0;
    overflow-y: auto;
    overflow-x: hidden;
    transition: width var(--transition-time);
    z-index: 1001;
    scrollbar-width: thin;
    border-right: 1px solid var(--border-light);
    box-shadow: 2px 0 8px rgba(0,0,0,.04);
}
.sidebar.collapsed { width: var(--sidebar-collapsed-width); }
.sidebar.collapsed .sidebar-title,
.sidebar.collapsed .menu-text,
.sidebar.collapsed .menu-arrow,
.sidebar.collapsed .submenu { display: none !important; }
.sidebar.collapsed .nav-link { justify-content: center; padding: 12px 0; }
.sidebar.collapsed .menu-group { display: none; }

.sidebar-logo {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    padding: 0 16px;
    background: var(--sidebar-dark);
    color: var(--text-primary);
    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    border-bottom: 1px solid var(--border-light);
}
.sidebar-logo .logo-icon { font-size: 22px; margin-right: 10px; color: var(--primary-color); }

/* 菜单分组标题 */
.sidebar .menu-group {
    color: var(--text-secondary);
    font-size: 13px;
    padding: 18px 20px 6px;
    letter-spacing: 1px;
    font-weight: 600;
    text-transform: uppercase;
    border-top: 1px solid var(--border-light);
    margin-top: 4px;
}
.sidebar .menu-group:first-child { border-top: none; margin-top: 0; }

/* 可折叠模块标题 */
.sidebar .menu-group-toggle {
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: background .15s;
    user-select: none;
    padding: 12px 20px;
    font-size: 16px;
    font-weight: 700;
    color: #00695c;
}
.sidebar .menu-group-toggle:hover { background: var(--sidebar-hover); color: #004d40; }
.sidebar .menu-group-toggle .menu-group-arrow {
    font-size: 12px;
    color: var(--text-placeholder);
    transition: transform .2s;
}
.sidebar .menu-group-toggle .menu-group-arrow.open { transform: rotate(180deg); }

/* 菜单项 */
.sidebar .nav-link {
    display: flex;
    align-items: center;
    color: var(--sidebar-text);
    padding: 0 20px;
    height: 46px;
    line-height: 46px;
    font-size: 15px;
    cursor: pointer;
    transition: all .15s;
    border-left: 3px solid transparent;
    white-space: nowrap;
    overflow: hidden;
    position: relative;
}
.sidebar .nav-link:hover {
    background: var(--sidebar-hover);
    color: var(--primary-color);
}
.sidebar .nav-link.active {
    background: var(--primary-color);
    color: #fff;
    border-left-color: var(--primary-light);
}
.sidebar .nav-link .menu-icon {
    width: 22px;
    text-align: center;
    margin-right: 10px;
    font-size: 18px;
    flex-shrink: 0;
    opacity: .85;
}
.sidebar .nav-link.active .menu-icon { opacity: 1; }
.sidebar .nav-link .menu-text { flex: 1; }
.sidebar .nav-link .menu-arrow {
    font-size: 12px;
    color: var(--text-placeholder);
    transition: transform .2s;
    flex-shrink: 0;
}
.sidebar .nav-link .menu-arrow.open { transform: rotate(90deg); color: var(--text-secondary); }

/* 子菜单 */
.sidebar .submenu .nav-link {
    padding-left: 52px;
    height: 40px;
    line-height: 40px;
    font-size: 13px;
}
.sidebar .submenu .nav-link::before {
    content: '';
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--text-placeholder);
    margin-right: 8px;
    flex-shrink: 0;
    position: absolute;
    left: 38px;
}
.sidebar .submenu .nav-link:hover::before,
.sidebar .submenu .nav-link.active::before { background: var(--primary-color); }
.sidebar .submenu .submenu .nav-link { padding-left: 68px; font-size: 12px; }
.sidebar .submenu .submenu .nav-link::before { left: 54px; }

/* ========== 主体区域 ========== */
.main-container {
    margin-left: var(--sidebar-width);
    height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left var(--transition-time);
    min-width: 800px;
}
.main-container.expanded { margin-left: var(--sidebar-collapsed-width); }

/* ========== 顶部导航栏 ========== */
.topbar {
    height: var(--topbar-height);
    background: var(--topbar-bg);
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    box-shadow: var(--topbar-shadow);
    position: relative;
    z-index: 10;
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }

/* 子系统选择器 */
.subsys-selector { display: flex; align-items: center; gap: 4px; }
.subsys-btn {
    padding: 6px 16px;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-regular);
    transition: all .2s;
    white-space: nowrap;
}
.subsys-btn:hover { background: #ecf5ff; color: var(--primary-color); }
.subsys-btn.active {
    background: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
}

.hamburger {
    width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; border-radius: 4px;
    color: var(--text-regular); font-size: 20px;
    transition: background .2s;
}
.hamburger:hover { background: #f5f5f5; }

.breadcrumb { display: flex; align-items: center; font-size: 13px; color: var(--text-secondary); }
.breadcrumb span + span::before { content: '/'; margin: 0 8px; color: var(--text-placeholder); }

.user-area { display: flex; align-items: center; gap: 8px; }
.user-avatar {
    width: 30px; height: 30px; border-radius: 50%;
    background: var(--primary-color); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 600;
}
.user-name { font-size: 14px; color: var(--text-primary); }

.badge-dot { position: relative; }
.badge-dot .badge-count {
    position: absolute; top: -4px; right: -6px;
    background: var(--danger-color); color: #fff;
    font-size: 10px; min-width: 16px; height: 16px;
    border-radius: 8px; display: flex; align-items: center;
    justify-content: center; padding: 0 4px;
    line-height: 1;
}

.topbar-btn {
    width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; border-radius: 4px; border: none;
    background: transparent; color: var(--text-regular);
    font-size: 18px; transition: all .2s; position: relative;
}
.topbar-btn:hover { background: #f5f5f5; color: var(--text-primary); }

/* ========== 页签栏 ========== */
.tab-bar {
    height: 36px;
    background: var(--topbar-bg);
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: stretch;
    padding: 0 8px;
    overflow-x: auto;
    overflow-y: hidden;
    flex-shrink: 0;
}
.tab-bar::-webkit-scrollbar { height: 0; }
.tab-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 14px;
    font-size: 12px;
    color: var(--text-regular);
    cursor: pointer;
    border-right: 1px solid var(--border-light);
    white-space: nowrap;
    position: relative;
    transition: color .15s;
    flex-shrink: 0;
    height: 100%;
}
.tab-item:hover { color: var(--primary-color); background: #f5f7fa; }
.tab-item.active {
    color: var(--primary-color);
    background: var(--body-bg);
    font-weight: 600;
}
.tab-item.active::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 2px;
    background: var(--primary-color);
}
.tab-item .tab-icon { font-size: 13px; }
.tab-item .tab-close {
    display: flex; align-items: center; justify-content: center;
    width: 16px; height: 16px; border-radius: 50%;
    font-size: 12px; color: var(--text-secondary);
    transition: all .15s;
    margin-left: 2px;
}
.tab-item .tab-close:hover { background: var(--danger-color); color: #fff; }
.tab-item.home .tab-close { display: none; }

/* 页签右键菜单 */
.tab-context-menu {
    position: fixed;
    background: #fff;
    border-radius: 6px;
    box-shadow: 0 4px 16px rgba(0,0,0,.12);
    border: 1px solid var(--border-light);
    padding: 4px 0;
    z-index: 9999;
    min-width: 160px;
    display: none;
}
.tab-context-menu .ctx-item {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 16px; font-size: 13px;
    color: var(--text-regular); cursor: pointer;
    transition: all .15s;
}
.tab-context-menu .ctx-item:hover { background: #f5f7fa; color: var(--primary-color); }
.tab-context-menu .ctx-item .ctx-icon { font-size: 14px; width: 16px; text-align: center; }
.tab-context-menu .ctx-item.disabled { color: var(--text-placeholder); pointer-events: none; }

/* ========== 内容区域 ========== */
.content-wrapper {
    flex: 1;
    overflow: hidden;
    background: var(--body-bg);
    position: relative;
}
.content-wrapper iframe {
    width: 100%; height: 100%; border: none;
    display: none;
}
.content-wrapper iframe.active { display: block; }

/* ========== 子页面通用样式 ========== */
.page-container {
    padding: 16px;
    min-height: 100%;
    background: var(--body-bg);
}

/* 面包屑导航 */
.page-breadcrumb {
    padding: 12px 16px;
    background: var(--card-bg);
    border-radius: var(--card-radius);
    margin-bottom: 16px;
    font-size: 13px;
    color: var(--text-secondary);
    box-shadow: var(--card-shadow);
}
.page-breadcrumb span { margin-right: 8px; }
.page-breadcrumb .sep { color: var(--text-placeholder); }

/* 搜索栏 */
.search-card {
    background: var(--card-bg);
    padding: 20px 20px 4px;
    border-radius: var(--card-radius);
    margin-bottom: 16px;
    box-shadow: var(--card-shadow);
}
.search-card .form-label { font-size: 13px; color: var(--text-regular); margin-bottom: 4px; }
.search-card .form-control, .search-card .form-select {
    border-radius: 4px; border-color: var(--border-color);
    font-size: 13px; transition: border-color .2s;
}
.search-card .form-control:focus, .search-card .form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(64,158,255,.2);
}

/* 表格卡片 */
.table-card {
    background: var(--card-bg);
    padding: 20px;
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
}
.table-card .card-header {
    display: flex; justify-content: space-between;
    align-items: center; margin-bottom: 16px;
    padding-bottom: 12px; border-bottom: 1px solid var(--border-light);
}
.table-card .card-title {
    font-size: 16px; font-weight: 600; color: var(--text-primary);
    position: relative; padding-left: 10px;
}
.table-card .card-title::before {
    content: ''; position: absolute; left: 0; top: 3px;
    width: 3px; height: 16px; background: var(--primary-color);
    border-radius: 2px;
}

/* ========== 按钮风格 ========== */
.btn-primary {
    background: var(--primary-color); border-color: var(--primary-color);
    border-radius: 4px; font-size: 13px; padding: 7px 15px;
    transition: all .2s;
}
.btn-primary:hover { background: var(--primary-light); border-color: var(--primary-light); }
.btn-primary:active { background: var(--primary-dark); border-color: var(--primary-dark); }

.btn-success {
    background: var(--success-color); border-color: var(--success-color);
    border-radius: 4px; font-size: 13px; padding: 7px 15px;
}
.btn-success:hover { background: #85ce61; border-color: #85ce61; }

.btn-danger {
    background: var(--danger-color); border-color: var(--danger-color);
    border-radius: 4px; font-size: 13px; padding: 7px 15px;
}
.btn-danger:hover { background: #f78989; border-color: #f78989; }

.btn-warning {
    background: var(--warning-color); border-color: var(--warning-color);
    border-radius: 4px; font-size: 13px; padding: 7px 15px; color: #fff;
}

.btn-info {
    background: var(--info-color); border-color: var(--info-color);
    border-radius: 4px; font-size: 13px; padding: 7px 15px; color: #fff;
}

.btn-default {
    background: #fff; border-color: var(--border-color);
    border-radius: 4px; font-size: 13px; padding: 7px 15px;
    color: var(--text-regular);
}
.btn-default:hover { color: var(--primary-color); border-color: var(--primary-light); background: #ecf5ff; }

.btn-text {
    background: transparent; border: none; color: var(--primary-color);
    padding: 4px 8px; font-size: 13px; cursor: pointer;
}
.btn-text:hover { color: var(--primary-light); }
.btn-text.danger { color: var(--danger-color); }
.btn-text.danger:hover { color: #f78989; }

.btn-sm { padding: 5px 12px; font-size: 12px; }

/* ========== 表格美化 ========== */
.bootstrap-table .fixed-table-container { border-radius: var(--card-radius); }
.bootstrap-table .table { border-radius: var(--card-radius); overflow: hidden; }
.bootstrap-table .table thead th {
    background: #fafafa; color: var(--text-regular);
    font-weight: 600; font-size: 13px;
    border-bottom: 1px solid var(--border-light);
    padding: 10px 12px;
}
.bootstrap-table .table tbody td {
    padding: 10px 12px; font-size: 13px;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}
.bootstrap-table .table tbody tr:hover { background: #f5f7fa; }
.bootstrap-table .table tbody tr:last-child td { border-bottom: none; }

/* 分页美化 */
.bootstrap-table .fixed-table-pagination {
    padding: 10px 16px; font-size: 13px; color: var(--text-regular);
}
.page-item.active .page-link {
    background: var(--primary-color); border-color: var(--primary-color);
}
.page-link { color: var(--primary-color); font-size: 13px; }

/* ========== 弹窗美化 ========== */
.modal-content { border-radius: 8px; border: none; box-shadow: 0 4px 24px rgba(0,0,0,.12); }
.modal-header {
    border-bottom: 1px solid var(--border-light);
    padding: 16px 20px;
}
.modal-title { font-size: 16px; font-weight: 600; color: var(--text-primary); }
.modal-body { padding: 20px; }
.modal-footer { border-top: 1px solid var(--border-light); padding: 12px 20px; }

/* ========== 表单美化 ========== */
.form-label { font-size: 13px; color: var(--text-regular); font-weight: 500; }
.form-control, .form-select {
    border-radius: 4px; border-color: var(--border-color);
    font-size: 13px; transition: border-color .2s;
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(64,158,255,.2);
}
.form-text { font-size: 12px; color: var(--text-secondary); }

/* ========== 标签/徽标 ========== */
.tag {
    display: inline-block; padding: 2px 8px; font-size: 12px;
    border-radius: 3px; line-height: 1.5;
}
.tag-primary { background: #ecf5ff; color: var(--primary-color); border: 1px solid #d9ecff; }
.tag-success { background: #f0f9eb; color: var(--success-color); border: 1px solid #e1f3d8; }
.tag-warning { background: #fdf6ec; color: var(--warning-color); border: 1px solid #faecd8; }
.tag-danger { background: #fef0f0; color: var(--danger-color); border: 1px solid #fde2e2; }
.tag-info { background: #f4f4f5; color: var(--info-color); border: 1px solid #e9e9eb; }

/* ========== 状态开关 ========== */
.switch {
    position: relative; display: inline-block;
    width: 40px; height: 20px; cursor: pointer;
}
.switch input { display: none; }
.switch .slider {
    position: absolute; inset: 0; background: var(--border-color);
    border-radius: 10px; transition: .3s;
}
.switch .slider::before {
    content: ''; position: absolute; width: 16px; height: 16px;
    left: 2px; bottom: 2px; background: #fff; border-radius: 50%;
    transition: .3s;
}
.switch input:checked + .slider { background: var(--primary-color); }
.switch input:checked + .slider::before { transform: translateX(20px); }

/* ========== 缩略图 ========== */
.thumb-img {
    width: 40px; height: 50px; object-fit: cover;
    border-radius: 4px; cursor: pointer;
    border: 1px solid var(--border-light);
    transition: transform .2s;
}
.thumb-img:hover { transform: scale(1.1); }
.thumb-img.qr { width: 40px; height: 40px; }

/* ========== 图片预览遮罩 ========== */
.img-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,.6);
    display: flex; align-items: center; justify-content: center;
    z-index: 9999; cursor: zoom-out;
}
.img-overlay img { max-width: 90%; max-height: 90%; border-radius: 8px; box-shadow: 0 8px 32px rgba(0,0,0,.3); }

/* ========== 空状态 ========== */
.empty-state {
    text-align: center; padding: 40px; color: var(--text-secondary);
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; color: var(--text-placeholder); }

/* ========== 工具栏 ========== */
.toolbar { display: flex; gap: 8px; align-items: center; }

/* ========== 统计卡片 ========== */
.stat-card {
    background: var(--card-bg); border-radius: var(--card-radius);
    padding: 20px; box-shadow: var(--card-shadow);
    text-align: center;
}
.stat-card .stat-num { font-size: 28px; font-weight: 700; color: var(--primary-color); }
.stat-card .stat-label { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }

/* ========== 动画 ========== */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.fade-in { animation: fadeIn .3s ease; }

/* ========== 响应式 ========== */
@media (max-width: 768px) {
    .sidebar { width: var(--sidebar-collapsed-width); }
    .sidebar .menu-text, .sidebar .menu-arrow, .sidebar .sidebar-title, .sidebar .submenu, .sidebar .menu-group { display: none !important; }
    .main-container { margin-left: var(--sidebar-collapsed-width); }
}
