/* ============================================
   左侧导航栏样式
   可收起/展开，底部个人资料可向上弹出
   深色主题
   ============================================ */

/* --- 整体页面布局 --- */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* --- 侧边栏 --- */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 220px;
    background: #0c0c1a;
    border-right: 1px solid rgba(255, 255, 255, 0.06);
    z-index: 300;
    display: flex;
    flex-direction: column;
    transition: width 0.28s ease;
    overflow: hidden;
    user-select: none;
}

.sidebar.collapsed {
    width: 60px;
}

/* --- 顶部区域：Logo + 收起按钮 --- */
.sidebar-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    height: 60px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    flex-shrink: 0;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-logo-icon {
    font-size: 1.4rem;
    flex-shrink: 0;
}

.sidebar-logo-text {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
    opacity: 1;
    transition: opacity 0.2s ease;
}

.sidebar.collapsed .sidebar-logo-text {
    opacity: 0;
    width: 0;
}

/* 收起/展开按钮 */
.sidebar-toggle-btn {
    width: 30px;
    height: 30px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.04);
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    transition: all var(--transition);
    flex-shrink: 0;
}

.sidebar-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
}

/* --- 中间导航区 --- */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px 10px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

/* 导航分隔线 */
.sidebar-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.05);
    margin: 8px 6px;
}

/* 导航项 */
.sidebar-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    overflow: hidden;
    position: relative;
}

.sidebar-nav-item:hover {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
}

.sidebar-nav-item.active {
    background: rgba(79, 110, 246, 0.12);
    color: var(--color-primary-light);
}

.sidebar-nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 20px;
    background: var(--color-primary);
    border-radius: 0 3px 3px 0;
}

.sidebar-nav-icon {
    font-size: 1.15rem;
    flex-shrink: 0;
    width: 22px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-nav-label {
    opacity: 1;
    transition: opacity 0.2s ease;
}

.sidebar.collapsed .sidebar-nav-label {
    opacity: 0;
    width: 0;
}

/* 收起状态下导航项居中显示 */
.sidebar.collapsed .sidebar-nav-item {
    justify-content: center;
    padding: 11px 8px;
    gap: 0;
}

.sidebar.collapsed .sidebar-nav-item.active::before {
    display: none;
}

/* 导航项提示气泡（收起态hover显示） */
.sidebar.collapsed .sidebar-nav-item::after {
    content: attr(data-tooltip);
    position: absolute;
    left: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%);
    background: #1e1e3a;
    color: var(--text-primary);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.82rem;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
    z-index: 400;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.sidebar.collapsed .sidebar-nav-item:hover::after {
    opacity: 1;
}

/* --- 底部分隔 --- */
.sidebar-spacer {
    flex: 1;
}

/* ============================================
   底部：个人资料区
   ============================================ */
.sidebar-profile {
    position: relative;
    padding: 8px 10px 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    flex-shrink: 0;
}

/* 个人资料按钮（底部始终显示） */
.profile-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
    font-family: var(--font-family);
    white-space: nowrap;
    overflow: hidden;
    text-align: left;
}

.profile-btn:hover {
    background: rgba(255, 255, 255, 0.04);
}

.profile-btn-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    color: #fff;
    font-weight: 600;
    flex-shrink: 0;
    overflow: hidden;
}

.profile-btn-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-btn-info {
    overflow: hidden;
    text-align: left;
    line-height: 1.3;
}

.profile-btn-name {
    font-size: 0.85rem;
    color: var(--text-primary);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.profile-btn-sub {
    font-size: 0.72rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.profile-btn-arrow {
    margin-left: auto;
    font-size: 0.6rem;
    color: var(--text-muted);
    transition: transform 0.25s ease;
    flex-shrink: 0;
}

.profile-btn.open .profile-btn-arrow {
    transform: rotate(180deg);
}

/* --- 剩余积分 --- */
.sidebar-credits {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    margin-top: 2px;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}

.sidebar-credits-icon {
    font-size: 0.95rem;
    flex-shrink: 0;
}

.sidebar-credits-label {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.sidebar-credits-value {
    margin-left: auto;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--color-accent-light);
    white-space: nowrap;
}

/* 收起态 */
.sidebar.collapsed .sidebar-credits {
    justify-content: center;
    padding: 8px 4px;
    gap: 0;
}

.sidebar.collapsed .sidebar-credits-label,
.sidebar.collapsed .sidebar-credits-value {
    display: none;
}

.sidebar.collapsed .sidebar-credits-icon {
    font-size: 1rem;
}

/* 收起态下个人资料按钮居中 */
.sidebar.collapsed .profile-btn {
    justify-content: center;
    padding: 10px 8px;
    gap: 0;
}

.sidebar.collapsed .profile-btn-info,
.sidebar.collapsed .profile-btn-arrow {
    display: none;
}

/* ============================================
   个人资料弹出面板
   ============================================ */
.profile-panel {
    position: absolute;
    bottom: calc(100% - 4px);
    left: 10px;
    right: 10px;
    background: #15152a;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-lg);
    padding: 16px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
    z-index: 350;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.25s ease;
    pointer-events: none;
}

.profile-panel.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
}

/* 弹出面板的三角箭头 */
.profile-panel::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid #15152a;
}

/* 面板顶部用户信息 */
.profile-panel-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
    padding-bottom: 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.profile-panel-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    color: #fff;
    font-weight: 600;
    flex-shrink: 0;
    overflow: hidden;
}

.profile-panel-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-panel-user {
    overflow: hidden;
    line-height: 1.4;
}

.profile-panel-nickname {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

.profile-panel-account {
    font-size: 0.76rem;
    color: var(--text-muted);
}

/* 信息行 */
.profile-panel-rows {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: 12px;
}

.profile-panel-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 7px 0;
    font-size: 0.82rem;
}

.profile-panel-row-label {
    color: var(--text-muted);
    flex-shrink: 0;
}

.profile-panel-row-value {
    color: var(--text-secondary);
    text-align: right;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-left: 12px;
}

/* QrgID行 — 带复制按钮 */
.qr-id-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 7px 0;
    font-size: 0.82rem;
}

.qr-id-row .profile-panel-row-label {
    color: var(--text-muted);
    flex-shrink: 0;
}

.qr-id-value-group {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: 12px;
}

.qr-id-value {
    color: var(--text-secondary);
    font-family: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
    font-size: 0.78rem;
}

.copy-btn {
    width: 26px;
    height: 26px;
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    transition: all var(--transition);
    flex-shrink: 0;
}

.copy-btn:hover {
    background: rgba(79, 110, 246, 0.15);
    color: var(--color-primary-light);
    border-color: rgba(79, 110, 246, 0.3);
}

.copy-btn.copied {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
    border-color: rgba(34, 197, 94, 0.3);
}

/* 面板菜单项 */
.profile-panel-menu {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.profile-panel-menuitem {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: 6px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 0.84rem;
    cursor: pointer;
    transition: all var(--transition);
    font-family: var(--font-family);
    text-decoration: none;
    width: 100%;
    text-align: left;
}

.profile-panel-menuitem:hover {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
}

.profile-panel-menuitem.danger {
    color: #ef4444;
}

.profile-panel-menuitem.danger:hover {
    background: rgba(239, 68, 68, 0.08);
}

.profile-panel-menuitem-icon {
    font-size: 0.95rem;
    flex-shrink: 0;
    width: 18px;
    text-align: center;
}

/* ============================================
   收起态下个人面板位置调整
   ============================================ */
.sidebar.collapsed .profile-panel {
    left: -6px;
    width: 240px;
}

.sidebar.collapsed .profile-panel::after {
    left: 28px;
}

/* ============================================
   主内容区偏移
   ============================================ */
.main-content {
    margin-left: 220px;
    flex: 1;
    min-height: 100vh;
    transition: margin-left 0.28s ease;
}

.main-content.sidebar-collapsed {
    margin-left: 60px;
}

/* ============================================
   遮罩层（移动端/点击外部关闭面板）
   ============================================ */
.profile-panel-overlay {
    position: fixed;
    inset: 0;
    z-index: 290;
    display: none;
}

.profile-panel-overlay.show {
    display: block;
}

/* ============================================
   复制成功 Toast
   ============================================ */
.toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #1e1e3a;
    color: #4ade80;
    padding: 10px 24px;
    border-radius: 8px;
    font-size: 0.85rem;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    border: 1px solid rgba(74, 222, 128, 0.2);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.toast.show {
    opacity: 1;
}

/* ============================================
   响应式
   ============================================ */
@media (max-width: 768px) {
    .sidebar {
        width: 60px;
    }

    .sidebar .sidebar-logo-text,
    .sidebar .sidebar-nav-label,
    .sidebar .profile-btn-info,
    .sidebar .profile-btn-arrow {
        display: none;
    }

    .sidebar .sidebar-nav-item {
        justify-content: center;
        padding: 11px 8px;
        gap: 0;
    }

    .sidebar .profile-btn {
        justify-content: center;
        padding: 10px 8px;
        gap: 0;
    }

    .main-content {
        margin-left: 60px;
    }

    .sidebar.collapsed {
        width: 60px;
    }

    /* 移动端显示悬浮展开按钮 */
    .sidebar-mobile-expand {
        display: flex;
        position: fixed;
        top: 12px;
        left: 68px;
        width: 34px;
        height: 34px;
        border-radius: 50%;
        background: var(--bg-card);
        border: 1px solid var(--border-color);
        color: var(--text-primary);
        align-items: center;
        justify-content: center;
        font-size: 1rem;
        z-index: 200;
        cursor: pointer;
        box-shadow: var(--shadow-md);
    }
}

@media (max-width: 480px) {
    .sidebar-mobile-expand {
        display: flex;
    }
}
