/**
 * 用户信息区域样式模块
 * 包含：用户信息显示、存储空间显示、用户下拉菜单等样式
 * 符合规范：CSS样式独立性，使用命名空间避免冲突
 */

/* ==================== 右侧操作区域 ==================== */

/* 右侧操作区域容器：min-width:0 便于在 flex 布局中收缩，防止整行溢出 */
.header-right-section {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin-left: auto;
    min-width: 0;
    flex-shrink: 1;
}

/* 各入口占位容器（仅布局，样式在各自独立 CSS 中） */
.global-message-bar-mount,
.debug-entry-wrapper,
.ai-chat-entry-wrapper,
.transfer-entry-wrapper,
.app-tools-entry-wrapper,
.more-menu-entry-wrapper,
.core-coin-entry-wrapper {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

/* ==================== 用户信息与空间使用包装容器 ==================== */

/* 用户信息与空间使用包装容器（包边容器）；允许在空间不足时收缩 */
.user-info-wrapper {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: 0 10px 0 4px; /* 垂直不设内边距，固定高度与 AI 聊天等入口 36px 对齐 */
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    backdrop-filter: blur(10px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-sm);
    box-sizing: border-box;
    height: 36px;
    min-height: 36px;
    max-height: 36px;
    line-height: 1;
    min-width: 0;
    flex-shrink: 1;
}

.user-info-wrapper:hover {
    background: var(--bg-hover);
    border-color: var(--border-secondary);
    box-shadow: var(--shadow-md);
}

/* 右侧用户信息区域容器 */
.user-info-wrapper > .user-info-container {
    display: flex;
    align-items: center;
    margin-left: 0;
    margin-right: 0;
}

/* 存储块为纵向（内层卡片 + 底部分列表浮层）；外层无独立底框 */
.user-info-wrapper > .user-storage-progress {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    align-self: center;
    margin-left: 0;
    margin-right: 0;
    border: none;
    background: transparent;
    padding: 0;
    box-shadow: none;
    max-height: 100%;
}

/* ==================== 用户信息容器 ==================== */

/* 用户信息容器样式 */
.user-info-container {
    display: flex;
    align-items: center;
    z-index: 10;
    gap: var(--spacing-xs);
    flex-shrink: 0;
}

/* 用户信息内容 */
.user-info-content {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: 8px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    backdrop-filter: blur(10px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
}

.user-info-content:hover {
    background: var(--bg-hover);
    border-color: var(--border-secondary);
    box-shadow: var(--shadow-sm);
}

/* 用户头像：方形 + 圆角（右上角用户信息区） */
.user-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 6px;
    color: white;
    flex-shrink: 0;
    box-shadow: 0 1px 4px rgba(102, 126, 234, 0.3);
}

.user-avatar-color {
    /* 色值由 avatar-utils 内联 style 传入 */
    border-radius: 6px;
}

.user-avatar-img {
    width: 24px;
    height: 24px;
    object-fit: cover;
    border-radius: 6px;
}

.user-avatar-fallback {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 6px;
}

/* 用户信息主区域 */
.user-info-main {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    flex: 1;
}

/* 用户名 */
.user-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
    font-family: "Microsoft YaHei", "微软雅黑", "SimSun", "宋体", "Arial", sans-serif;
    white-space: nowrap;
    line-height: 1.2;
}

/* ==================== 角色徽章样式 ==================== */

/* 角色徽章基础样式 */
.user-role-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 500;
    font-family: "Microsoft YaHei", "微软雅黑", "SimSun", "宋体", "Arial", sans-serif;
    white-space: nowrap;
    line-height: 1.2;
    transition: all 0.2s ease;
}

.user-role-badge .role-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 12px;
    height: 12px;
    flex-shrink: 0;
}

.user-role-badge .role-text {
    line-height: 1;
}

/* 普通用户样式 */
.user-role-badge.role-user {
    background: linear-gradient(135deg, rgba(52, 152, 219, 0.2) 0%, rgba(52, 152, 219, 0.3) 100%);
    color: #5dade2;
    border: 1px solid rgba(52, 152, 219, 0.4);
    box-shadow: 0 1px 3px rgba(52, 152, 219, 0.2);
}

.user-role-badge.role-user .role-icon {
    color: #5dade2;
}

/* 管理员样式 */
.user-role-badge.role-admin {
    background: linear-gradient(135deg, rgba(243, 156, 18, 0.2) 0%, rgba(243, 156, 18, 0.3) 100%);
    color: #f7dc6f;
    border: 1px solid rgba(243, 156, 18, 0.4);
    box-shadow: 0 1px 3px rgba(243, 156, 18, 0.2);
}

.user-role-badge.role-admin .role-icon {
    color: #f7dc6f;
}

/* 超级管理员样式 */
.user-role-badge.role-superadmin {
    background: linear-gradient(135deg, rgba(231, 76, 60, 0.25) 0%, rgba(231, 76, 60, 0.35) 100%);
    color: #ec7063;
    border: 1px solid rgba(231, 76, 60, 0.5);
    box-shadow: 0 2px 6px rgba(231, 76, 60, 0.3), 0 0 8px rgba(231, 76, 60, 0.15);
}

.user-role-badge.role-superadmin .role-icon {
    color: #ec7063;
}

/* ==================== 用户下拉菜单 ==================== */

/* 用户下拉菜单容器 */
.user-dropdown {
    position: relative;
    display: inline-block;
}

/* 用户下拉菜单按钮 */
.user-dropdown-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 8px 0 2px; /* 垂直留白交给外层 36px 对齐，避免总高度被撑高 */
    background: transparent;
    border: none;
    border-radius: 0;
    backdrop-filter: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    cursor: pointer;
    font-family: "Microsoft YaHei", "微软雅黑", "SimSun", "宋体", "Arial", sans-serif;
    box-shadow: none;
}

.user-dropdown-btn:hover {
    background: transparent;
    border: none;
    box-shadow: none;
    transform: none;
}

.user-dropdown-btn:active {
    transform: none;
    box-shadow: none;
}

/* 下拉箭头 */
.dropdown-arrow {
    transition: transform 0.3s ease;
    color: var(--text-secondary);
    flex-shrink: 0;
    margin-left: 2px;
    width: 10px;
    height: 10px;
}

.user-dropdown-btn:hover .dropdown-arrow {
    transform: translateY(2px) rotate(180deg);
    color: var(--text-primary);
}

/* 用户下拉菜单 */
.user-dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 200px;
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(20px);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    overflow: hidden;
}

.user-dropdown-menu.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* 下拉菜单项 */
.dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 13px;
    font-family: "Microsoft YaHei", "微软雅黑", "SimSun", "宋体", "Arial", sans-serif;
    border-bottom: 1px solid var(--border-primary);
    position: relative;
}

.dropdown-item:first-child {
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
}

.dropdown-item:last-child {
    border-bottom: none;
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 12px;
}

.dropdown-item:hover {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.15) 0%, rgba(102, 126, 234, 0.25) 100%);
    color: var(--text-primary);
    transform: translateX(2px);
}

.dropdown-item:active {
    transform: translateX(0);
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.25) 0%, rgba(102, 126, 234, 0.35) 100%);
}

.dropdown-item svg {
    width: 16px;
    height: 16px;
    color: var(--text-secondary);
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.dropdown-item:hover svg {
    color: var(--text-primary);
    transform: scale(1.1);
}

/* 管理后台链接（在下拉菜单中） */
.admin-link-dropdown {
    color: var(--text-primary);
    text-decoration: none;
    font-family: "Microsoft YaHei", "微软雅黑", "SimSun", "宋体", "Arial", sans-serif;
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
}

.admin-link-dropdown:hover {
    color: var(--text-primary);
}

/* ==================== 存储空间进度条 ==================== */

/* 用户空间进度条容器（relative 供储存空间细分浮层定位；内层 user-storage-progress-inner 为深色小卡片） */
.user-storage-progress {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 0;
    min-width: 0;
    max-width: 220px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 0;
    flex-shrink: 1;
}

/* 与后台头部一致的存储子容器：深灰底、圆角、内边距 */
.user-storage-progress-inner {
    width: 100%;
    min-width: 140px;
    max-width: 220px;
    padding: 2px 6px;
    background: var(--bg-secondary, rgba(0, 0, 0, 0.22));
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-sm, 6px);
    box-sizing: border-box;
}

/* 与 36px 外框对齐：压缩存储子卡片（仅用户信息包装器内） */
.user-info-wrapper .user-storage-progress-inner {
    padding: 1px 6px;
}

/* 空间进度条hover效果（仅在独立显示时生效） */
.search-section > .user-storage-progress:hover {
    background: var(--bg-hover);
    border-color: var(--border-secondary);
    box-shadow: var(--shadow-sm);
}

/* 在包装容器内的空间进度条不显示hover效果（由外层容器统一处理） */
.user-info-wrapper > .user-storage-progress:hover {
    background: transparent;
    border-color: transparent;
    box-shadow: none;
}

/* 上行文案区域（与后台 header 一致：浅灰字、不占满进度条） */
.storage-progress-info {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    width: 100%;
    margin-bottom: 4px;
}

.user-info-wrapper .storage-progress-info {
    margin-bottom: 1px;
}

.storage-text {
    position: static;
    display: block;
    font-size: 10px;
    font-weight: 500;
    color: var(--text-secondary);
    font-family: "Microsoft YaHei", "微软雅黑", "SimSun", "宋体", "Arial", sans-serif;
    white-space: nowrap;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 包装容器内：细进度条 + 浅绿默认填充（具体颜色仍由 storage-info.js 按占比覆盖） */
.user-info-wrapper > .user-storage-progress .storage-progress-bar {
    height: 4px;
    min-height: 4px;
    border-radius: 2px;
}

.user-info-wrapper > .user-storage-progress .storage-text {
    font-size: 11px;
    line-height: 1.2;
}

.user-info-wrapper > .user-storage-progress .storage-progress-fill {
    border-radius: 2px;
}

/* 进度条容器 */
.storage-progress-bar-container {
    width: 100%;
}

/* 进度条轨道（深灰底，与示意图一致） */
.storage-progress-bar {
    width: 100%;
    height: 6px;
    min-height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    overflow: hidden;
    position: relative;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.25);
}

/* 进度条填充（默认浅绿；JS 仍按阈值改为黄/红） */
.storage-progress-fill {
    height: 100%;
    background: #90ee90;
    border-radius: 3px;
    transition: width 0.3s ease, background-color 0.3s ease;
    box-shadow: none;
    position: relative;
    overflow: hidden;
}

/* 进度条填充动画效果 */
.storage-progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.2),
        transparent
    );
    animation: progressShine 2s infinite;
}

@keyframes progressShine {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

/* 移动端响应式已移除（项目仅支持 Windows 桌面端） */

