/* ==================== 全局变量 ==================== */
:root {
    --primary-blue: #1e5672;
    --accent-teal: #2dbece;
    --brand-orange: #FF8C42;
    --text-muted: #6c757d;
    --bg-main: #f8fafc;
    --sidebar-width: 240px;
}

/* ==================== 布局 ==================== */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg-main);
    color: #1e293b;
    font-size: 14px;
}
.wrapper { display: flex; min-height: 100vh; }

/* ==================== 侧边栏 ==================== */
/* 同时匹配 #sidebar-container 和 sidebar.js 改名后的 #sidebar */
#sidebar-container, #sidebar {
    width: var(--sidebar-width);
    background: #F7E8DA;  /* 原型：浅奶油杏 */
    color: #5A2D0F;       /* 原型：深棕橙文字 */
    position: fixed; top: 0; left: 0; bottom: 0;
    z-index: 1000; overflow-y: auto;
    border-right: 1px solid rgba(122, 61, 24, 0.08);
}
#sidebar-container .sidebar-header, #sidebar .sidebar-header {
    padding: 20px;
    color: #5A2D0F;
    font-weight: 700;
    font-size: 1.2rem;
    background: #F5DFCC;  /* 原型：略深一档头部 */
    border-bottom: 1px solid rgba(122, 61, 24, 0.08);
}
#sidebar-container .sidebar-nav, #sidebar .sidebar-nav {
    list-style: none; padding: 8px 0;
}
#sidebar-container .sidebar-nav li a, #sidebar .sidebar-nav li a {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 20px;
    color: #5A2D0F;       /* 原型：深棕橙 */
    text-decoration: none;
    transition: all .15s;
    font-size: 1rem;
    border-left: 4px solid transparent;
}
#sidebar-container .sidebar-nav li a:hover,
#sidebar-container .sidebar-nav li a.active,
#sidebar .sidebar-nav li a:hover,
#sidebar .sidebar-nav li a.active {
    color: #5A2D0F;
    background: rgba(230, 126, 34, 0.08);   /* 原型：橙色 8% 透明 */
    border-left-color: #E67E22;             /* 原型：深暖橙左边框 */
}
#sidebar-container .sidebar-nav li a i,
#sidebar .sidebar-nav li a i {
    width: 20px;
    text-align: center;
    color: #7A4F3A;   /* 原型：次要文字/图标色 */
}
#sidebar-container .sidebar-nav li a:hover i,
#sidebar-container .sidebar-nav li a.active i,
#sidebar .sidebar-nav li a:hover i,
#sidebar .sidebar-nav li a.active i {
    color: #E67E22;   /* 原型：active 图标变深暖橙 */
}
#sidebar-container .sidebar-nav li.sidebar-group,
#sidebar .sidebar-nav li.sidebar-group {
    padding: 10px 20px 5px;
    font-size: .75rem;
    color: #5A2D0F;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 700;
}
.sidebar-loaded { opacity: 1; }

/* ==================== 内容区 ==================== */
#content {
    margin-left: var(--sidebar-width); flex: 1; min-width: 0;
}
#content .navbar {
    background: rgba(255,255,255,.9); backdrop-filter: blur(6px);
    border-bottom: 1px solid #e2e8f0; padding: 10px 24px;
}
.text-primary-blue { color: var(--primary-blue) !important; }
.main-content { padding: 20px 24px; max-width: 1400px; margin: 0 auto; }

/* ==================== 版本图例 ==================== */
.version-legend {
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
    padding: 10px 16px; background: #fff; border-radius: 10px; margin-bottom: 16px;
    box-shadow: 0 1px 4px rgba(0,0,0,.04); font-size: .8rem;
}
.legend-title { font-weight: 700; color: var(--text-muted); }
.legend-item { display: flex; align-items: center; gap: 4px; color: var(--text-muted); }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot-v05 { background: var(--brand-orange); }

/* ==================== 版本标签 ==================== */
.v05-tag {
    background: var(--brand-orange); color: #fff; font-size: .72rem;
    font-weight: 700; padding: 2px 8px; border-radius: 6px; margin-right: 8px;
}
.func-nav {
    display: flex; justify-content: space-between; padding: 16px 0;
    border-top: 1px solid #e2e8f0; margin-top: 24px;
}
.func-nav a { color: var(--text-muted); text-decoration: none; font-size: .85rem; }
.func-nav a:hover { color: var(--accent-teal); }

/* V1 标签 */
.v1-tag {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
    background: #e0e0e0;
    color: #616161;
}

/* 图例圆点 */
.dot-v1 {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #9e9e9e;
    margin-right: 4px;
}

.dot-v2 {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #bdbdbd;
    margin-right: 4px;
}


/* 头像 */
.staff-avatar {
    width: 36px; height: 36px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 700; font-size: .92rem; flex-shrink: 0;
}
.av-orange { background: linear-gradient(135deg,#FF8C42,#FFB627); }
.av-blue   { background: linear-gradient(135deg,#1e5672,#2dbece); }
.av-green  { background: linear-gradient(135deg,#16a34a,#22c55e); }
.av-purple { background: linear-gradient(135deg,#6b21a8,#a855f7); }
.av-pink   { background: linear-gradient(135deg,#9d174d,#f472b6); }
.av-gray   { background: linear-gradient(135deg,#64748b,#94a3b8); }

/* 组织架构树 */
.org-tree { padding: 6px 0 0 6px; }
.org-tree ul { padding-left: 30px; position: relative; margin: 0; list-style: none; }
.org-tree > ul { padding-left: 0; }
.org-tree li { position: relative; padding: 14px 0 0 26px; list-style: none; }
.org-tree > ul > li { padding-left: 0; }
.org-tree li::before {
    content: ''; position: absolute; left: 0; top: 0;
    width: 2px; height: 100%; background: #cbd5e1;
}
.org-tree > ul > li::before { display: none; }
.org-tree li::after {
    content: ''; position: absolute; left: 0; top: 28px;
    width: 26px; height: 2px; background: #cbd5e1;
}
.org-tree > ul > li::after { display: none; }
.org-tree li:last-child::before { height: 28px; }

/* 组织节点卡片 */
.org-node-card {
    display: inline-flex; align-items: center; gap: 12px;
    background: #fff; border-radius: 10px; padding: 10px 16px;
    box-shadow: 0 2px 8px rgba(30,86,114,.08);
    border: 2px solid #eef2f6; transition: all .15s; min-width: 180px;
}

/* 可编辑/只读模式切换：企业端加 .editable 启用 hover，平台端不加为只读 */
.org-tree.editable .org-node-card:hover {
    border-color: var(--accent-teal);
    transform: translateY(-1px);
}
.org-node-card.is-boss { border-color: var(--brand-orange); background: #fff7ed; }
.org-node-card.is-leader { border-color: var(--primary-blue); background: #eff6ff; }

/* 角色小药丸 */
.role-pill { font-size: .68rem; padding: 1px 7px; border-radius: 8px; font-weight: 600; }
.rp-super_admin { background:#f1f5f9; color:#475569; }
.rp-boss  { background:#ffedd5; color:#9a3412; }
.rp-hr    { background:#fef3c7; color:#92400e; }
.rp-pm    { background:#e0e7ff; color:#3730a3; }
.rp-leader{ background:#dbeafe; color:#1e40af; }
.rp-qa    { background:#f3e8ff; color:#6b21a8; }
.rp-worker{ background:#dcfce7; color:#166534; }

/* 组织列表项 */
.company-item {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px 8px 36px; border-radius: 8px; cursor: pointer;
    border: 2px solid transparent; transition: all .15s; margin-bottom: 4px;
}
.company-item:hover { background: #f8fafc; }
.company-item.active { border-color: var(--accent-teal); background: #ecfeff; }
.company-item .ci-name { font-weight: 600; font-size: .85rem; }
.company-item .ci-meta { font-size: .76rem; color: var(--text-muted); }

/* 登录覆盖层 */
.login-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,.5); z-index: 9999;
    display: flex; align-items: center; justify-content: center;
}
.login-overlay .card { width: 360px; }

/* ==================== "?" 号提示 popover（公共组件，ui-popover.js 配套） ==================== */
.progress-legend-trigger {
    color: #94a3b8;
    cursor: pointer;
    font-size: 0.75rem;
    transition: color 0.15s;
}

.progress-legend-trigger:hover {
    color: #1e5672;
}

.progress-legend-popover {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background: #1e293b;
    color: #fff;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.72rem;
    font-weight: 400;
    line-height: 1.7;
    white-space: normal;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
    z-index: 20;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    max-width: 320px;
}

.progress-legend-popover.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.legend-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.legend-dot.legend-green { background: #16a34a; }
.legend-dot.legend-red { background: #dc2626; }
.legend-dot.legend-orange { background: #d97706; }
.legend-dot.legend-blue { background: #1e5672; }
.legend-dot.legend-gray { background: #94a3b8; }

.legend-hint {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid rgba(255,255,255,0.2);
    color: #94a3b8;
    font-size: 0.65rem;
}

/* ==================== 消息下拉面板（message-bell.js 配套） ==================== */
/* 确保铃铛下拉面板浮在内容区卡片之上 */
#topbar-container {
    position: relative;
    z-index: 1000;
}
/* 铃铛抖动动画（新消息到达时触发一次） */
/* a 标签默认 inline，transform 不生效，需 inline-block */
#message-bell-btn {
    display: inline-block;
}
.bell-shake {
    animation: bell-shake 0.8s ease;
}
@keyframes bell-shake {
    0%, 100% { transform: rotate(0); }
    10%, 30%, 50%, 70%, 90% { transform: rotate(-12deg); }
    20%, 40%, 60%, 80% { transform: rotate(12deg); }
}
.message-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 320px;
    max-height: 420px;
    overflow-y: auto;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    z-index: 1050;
    border: 1px solid #e2e8f0;
}
.message-dropdown-header {
    padding: 12px 16px;
    border-bottom: 1px solid #e2e8f0;
    font-size: 0.9rem;
}
.message-dropdown-body {
    padding: 4px 0;
}
.message-item {
    padding: 10px 16px;
    cursor: pointer;
    transition: background 0.15s;
    border-bottom: 1px solid #f1f5f9;
}
.message-item:last-child {
    border-bottom: none;
}
.message-item:hover {
    background: #f8fafc;
}
.message-item-unread {
    background: #eff6ff;
}
.message-item-unread:hover {
    background: #dbeafe;
}
.message-item-title {
    font-size: 0.85rem;
    color: #1e293b;
    margin-bottom: 2px;
}
.message-item-content {
    font-size: 0.8rem;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.message-item-time {
    font-size: 0.75rem;
    margin-top: 4px;
}
.message-delete-btn {
    font-size: 0.75rem;
    opacity: 0.4;
    transition: opacity 0.15s;
    white-space: nowrap;
}
.message-delete-btn:hover {
    opacity: 1;
}
