/* ========== 管理后台布局 ========== */
html, body {
    height: 100%;
    overflow: hidden;
}

.admin-layout {
    display: flex;
    height: 100vh;
    background: #F5F5F8;
}

/* ========== 侧边栏 ========== */
.admin-sidebar {
    width: 220px;
    min-width: 220px;
    background: var(--dark);
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 100;
    transition: width 0.3s ease, min-width 0.3s ease;
}

.admin-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.admin-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}

.admin-logo .logo-img {
    width: 30px; height: 30px;
    border-radius: 6px;
    object-fit: cover;
}

.admin-brand {
    font-size: 0.95rem;
    font-weight: 800;
    color: var(--white);
    white-space: nowrap;
}

.sidebar-collapse-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.35);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: 0.2s;
    display: none;
}

.sidebar-collapse-btn:hover {
    color: var(--white);
    background: rgba(255, 255, 255, 0.08);
}

/* 导航 */
.admin-nav {
    flex: 1;
    padding: 12px 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow-y: auto;
}

.admin-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: 6px;
    color: rgba(255, 255, 255, 0.5);
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 500;
    transition: all 0.2s;
}

.admin-nav-item:hover {
    background: rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.8);
}

.admin-nav-item.active {
    background: var(--primary);
    color: var(--white);
}

.admin-nav-item svg { flex-shrink: 0; }

.admin-sidebar-footer {
    padding: 12px 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

/* ========== 主内容 ========== */
.admin-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

.admin-topbar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 24px;
    background: var(--white);
    border-bottom: 1px solid #F0F0F4;
}

.admin-topbar h2 {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--dark);
}

.admin-topbar-right {
    margin-left: auto;
}

.admin-badge {
    padding: 4px 14px;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 50px;
    font-size: 0.8rem;
    font-weight: 700;
}

.menu-trigger {
    display: none;
    background: none;
    border: none;
    color: var(--text);
    cursor: pointer;
    padding: 4px;
}

/* 内容区 */
.admin-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.admin-tab { display: none; }
.admin-tab.active { display: block; animation: fadeIn 0.3s ease; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ========== 卡片 ========== */
.admin-card {
    background: var(--white);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.04);
}

.admin-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid #F0F0F4;
    flex-wrap: wrap;
    gap: 12px;
}

.admin-card-header h3 {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--dark);
}

.admin-card-header p {
    font-size: 0.82rem;
    color: var(--text-light);
    margin-top: 2px;
}

.admin-card-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.admin-search {
    padding: 8px 14px;
    border: 1px solid #E0E0E8;
    border-radius: 6px;
    font-size: 0.85rem;
    outline: none;
    width: 200px;
    font-family: inherit;
    transition: border-color 0.2s;
}

.admin-search:focus { border-color: var(--primary); }

/* ========== 表格 ========== */
.admin-table-wrap { overflow-x: auto; }

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.admin-table th {
    background: #FAFAFC;
    padding: 13px 16px;
    text-align: left;
    font-weight: 700;
    color: var(--text-light);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    white-space: nowrap;
    border-bottom: 1px solid #F0F0F4;
}

.admin-table td {
    padding: 12px 16px;
    border-bottom: 1px solid #F5F5F8;
    color: var(--text);
    vertical-align: middle;
}

.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: #FAFAFD; }

.table-empty td {
    text-align: center;
    color: var(--text-light);
    padding: 48px 16px !important;
    font-size: 1rem;
}

.ofc-tag {
    display: inline-block;
    padding: 3px 10px;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 4px;
    font-weight: 700;
    font-size: 0.82rem;
}

.method-tag {
    padding: 3px 10px;
    background: #E8F8EE;
    color: #07C160;
    border-radius: 4px;
    font-size: 0.78rem;
    font-weight: 600;
}

.status-tag {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 0.78rem;
    font-weight: 600;
}

.status-tag.active { background: #E8F8EE; color: #07C160; }
.status-tag.disabled { background: #F0F0F4; color: #999; }
.status-tag.expired { background: #FDEAEC; color: var(--primary); }

.invite-code {
    background: #F5F5F8;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 800;
    color: var(--primary);
    letter-spacing: 0.04em;
}

/* 操作按钮 */
.btn-action {
    padding: 4px 12px;
    border: none;
    border-radius: 4px;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: 0.15s;
    margin-right: 4px;
}

.btn-action-edit { background: #EEF0F8; color: #5560AA; }
.btn-action-edit:hover { background: #DDE0F0; }
.btn-action-danger { background: #FDEAEC; color: var(--primary); }
.btn-action-danger:hover { background: #FBD0D6; }
.btn-action-copy { background: #E8F8EE; color: #07C160; }
.btn-action-copy:hover { background: #D0F0E0; }
.btn-action-invite { background: #FFF3E0; color: #FF9800; }
.btn-action-invite:hover { background: #FFE6C0; }

/* ========== 组织架构 ========== */
.org-tree {
    padding: 20px 24px 28px 24px;
    overflow-x: auto;
}

/* 树项 */
.org-tree-item {
    position: relative;
}

/* 树行 */
.org-tree-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: #FAFAFC;
    border-radius: var(--radius-sm);
    border: 1px solid #F0F0F4;
    transition: 0.2s;
    position: relative;
    margin-bottom: 4px;
}

.org-tree-row:hover {
    border-color: #D8D8E0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.03);
}

/* 层级连接线 */
.org-tree-lines {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 36px;
    pointer-events: none;
    opacity: 0.3;
}

.org-line-v {
    position: absolute;
    left: 14px;
    top: -4px;
    bottom: 50%;
    width: 2px;
    background: #C8C8D4;
}

.org-line-h {
    position: absolute;
    left: 14px;
    top: 50%;
    width: 16px;
    height: 2px;
    background: #C8C8D4;
}

/* 折叠按钮 */
.org-toggle {
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 4px;
    color: #888;
    flex-shrink: 0;
    transition: 0.2s;
}

.org-toggle:hover {
    background: #E8E8EE;
    color: #555;
}

.org-toggle svg {
    transition: transform 0.25s ease;
}

.org-toggle-empty {
    visibility: hidden;
}

/* 层级标签 */
.org-level-badge {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 3px;
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    flex-shrink: 0;
    background: #E8E8EE;
    color: #707078;
}

.org-tree-row:nth-child(1) .org-level-badge,
.org-tree-row[style*="padding-left:0px"] .org-level-badge { background: #2D2D3A; color: #FFF; }
.org-tree-row[style*="padding-left:36px"] .org-level-badge { background: var(--primary-light); color: var(--primary); }
.org-tree-row[style*="padding-left:72px"] .org-level-badge { background: #FFF3E0; color: #E67E22; }
.org-tree-row[style*="padding-left:108px"] .org-level-badge { background: #E8F4FD; color: #2980B9; }

.org-node-icon { font-size: 1.3rem; flex-shrink: 0; }

.org-node-info { flex: 1; min-width: 0; }

.org-node-info strong {
    display: block;
    color: var(--dark);
    font-size: 0.93rem;
}

.org-node-sub {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 2px;
    flex-wrap: wrap;
}

.org-node-desc {
    font-size: 0.78rem;
    color: var(--text-light);
}

.org-node-meta {
    font-size: 0.75rem;
    color: var(--primary);
    font-weight: 600;
}

.org-node-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

/* 子组织容器 */
.org-children {
    overflow: hidden;
    transition: max-height 0.35s ease, opacity 0.35s ease;
    max-height: 2000px;
}

.org-children.collapsed {
    max-height: 0;
    opacity: 0;
}

/* 添加子组织按钮 */
.btn-action-add {
    background: #E8F4FD;
    color: #2980B9;
}

.btn-action-add:hover {
    background: #D0E8F8;
}

.empty-state {
    text-align: center;
    padding: 48px;
    color: var(--text-light);
    font-size: 1rem;
}

/* ========== OFC二维码卡片 ========== */
.qr-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    padding: 24px;
}

.qr-card {
    background: var(--white);
    border-radius: var(--radius);
    border: 1px solid #F0F0F4;
    overflow: hidden;
    transition: box-shadow 0.25s, transform 0.25s;
}

.qr-card:hover {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
}

.qr-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #F5F5F8;
    gap: 12px;
}

.qr-card-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.qr-card-info strong {
    font-size: 0.95rem;
    color: var(--dark);
    font-weight: 800;
}

.qr-card-info span {
    font-size: 0.75rem;
    color: var(--text-light);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.qr-card-badge {
    display: inline-block;
    padding: 3px 10px;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 50px;
    font-size: 0.72rem;
    font-weight: 700;
    white-space: nowrap;
    flex-shrink: 0;
}

.qr-card-body {
    display: flex;
    justify-content: center;
    padding: 24px 20px;
}

.qr-code-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 160px;
    height: 160px;
    border-radius: 8px;
    overflow: hidden;
}

.qr-code-wrap canvas,
.qr-code-wrap img {
    border-radius: 8px;
}

.qr-card-footer {
    display: flex;
    gap: 8px;
    padding: 0 20px 20px;
}

.qr-card-footer .btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 0.8rem;
    padding: 8px 12px;
}

.qr-card-footer .btn svg {
    flex-shrink: 0;
}

/* 移动端适配 */
@media (max-width: 768px) {
    .qr-grid {
        grid-template-columns: 1fr;
        padding: 16px;
        gap: 16px;
    }
}

/* ========== 弹窗 ========== */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--white);
    border-radius: var(--radius);
    width: 100%;
    max-width: 480px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    animation: modalIn 0.25s ease;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(-10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid #F0F0F4;
}

.modal-header h4 {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--dark);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-light);
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

.modal-close:hover { color: var(--dark); }

.modal-body {
    padding: 24px;
}

.modal-body .form-group {
    margin-bottom: 18px;
}

.modal-body .form-group label {
    display: block;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--dark);
    margin-bottom: 6px;
}

.modal-body .input-group {
    display: flex;
    gap: 8px;
    align-items: center;
}

.modal-body .input-group input[type="text"] {
    flex: 1;
}

.modal-body .input-group .btn {
    flex-shrink: 0;
    white-space: nowrap;
}

.modal-body input[type="text"],
.modal-body input[type="number"],
.modal-body select {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid #E8E8EE;
    border-radius: 6px;
    font-size: 0.9rem;
    color: var(--dark);
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}

.modal-body input:focus,
.modal-body select:focus {
    border-color: var(--primary);
}

.modal-body input:disabled {
    background: #F5F5F8;
    color: var(--text-light);
}

.modal-body select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%237B7B8B' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
}

.form-hint {
    display: block;
    font-size: 0.78rem;
    color: var(--text-light);
    margin-top: 4px;
}

/* ========== 级联下拉菜单 ========== */
.cascade-dropdown {
    position: relative;
}

.cascade-input {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 14px;
    border: 2px solid #E8E8EE;
    border-radius: 6px;
    font-size: 0.9rem;
    min-height: 44px;
    cursor: pointer;
    background: #fff;
    transition: border-color 0.2s;
    user-select: none;
}

.cascade-input:hover {
    border-color: #C8C8D8;
}

.cascade-input.open {
    border-color: var(--primary);
}

.cascade-placeholder {
    color: #B0B0C0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cascade-placeholder.selected {
    color: var(--dark);
    font-weight: 600;
}

.cascade-arrow-icon {
    color: #B0B0C0;
    flex-shrink: 0;
    transition: transform 0.2s;
}

.cascade-input.open .cascade-arrow-icon {
    transform: rotate(180deg);
    color: var(--primary);
}

/* 下拉菜单面板 */
.cascade-menu {
    position: absolute;
    left: 0;
    top: calc(100% + 4px);
    display: flex;
    background: #fff;
    border: 1px solid #E8E8EE;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.12);
    z-index: 1050;
    min-width: 480px;
    overflow: hidden;
}

.cascade-menu-col {
    flex: 1;
    min-width: 140px;
    border-right: 1px solid #F0F0F4;
    background: #fff;
}

.cascade-menu-col:last-child {
    border-right: none;
}

.cascade-menu-list {
    max-height: 220px;
    overflow-y: auto;
    padding: 4px 0;
}

.cascade-menu-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 16px;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text);
    transition: all 0.12s;
    white-space: nowrap;
}

.cascade-menu-item:hover {
    background: #F0F0F6;
    color: var(--primary);
}

.cascade-menu-item.selected {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 700;
}

.cascade-menu-item .item-arrow {
    font-size: 0.8rem;
    color: #C0C0D0;
    flex-shrink: 0;
    margin-left: 8px;
}

.cascade-menu-item:hover .item-arrow {
    color: var(--primary);
}

.cascade-empty {
    padding: 20px 16px;
    text-align: center;
    color: #C0C0D0;
    font-size: 0.82rem;
}

/* ========== 旧版级联选择器（已废弃，保留兼容） ========== */
.cascade-selector {
    display: none;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 24px;
    border-top: 1px solid #F0F0F4;
    background: #FAFAFC;
}

/* Toast */
.toast {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(-120px);
    background: var(--dark);
    color: var(--white);
    padding: 12px 28px;
    border-radius: 50px;
    font-size: 0.92rem;
    font-weight: 600;
    z-index: 2000;
    transition: transform 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
    pointer-events: none;
}

.toast.show { transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--primary); }
.toast.success { background: #07C160; }

/* ========== 响应式 ========== */
@media (max-width: 768px) {
    .admin-sidebar {
        position: fixed;
        left: -100%;
        top: 0; bottom: 0;
        width: 240px;
        min-width: 240px;
        transition: left 0.3s;
        z-index: 200;
    }

    .admin-sidebar.open { left: 0; }
    .menu-trigger { display: flex; }
    .admin-topbar { padding: 12px 16px; }
    .admin-content { padding: 16px; }
    .admin-search { width: 140px; }
    .admin-table th, .admin-table td { padding: 10px 12px; font-size: 0.8rem; }
}
