/* =====================================================
   云端文件管理系统 - 全局样式
   简洁轻量化后台UI，响应式布局
   ===================================================== */

/* ---------- 基础重置 ---------- */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
                 "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    color: #333;
    background: #f0f2f5;
    line-height: 1.6;
}
a { color: #1890ff; text-decoration: none; }
a:hover { color: #40a9ff; }
ul, ol { list-style: none; }
img { max-width: 100%; vertical-align: middle; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; font-size: 14px; }

/* ---------- 通用工具 ---------- */
.clearfix::after { content: ''; display: block; clear: both; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: #999; }
.text-danger { color: #ff4d4f; }
.text-success { color: #52c41a; }
.text-warning { color: #faad14; }
.pull-left { float: left; }
.pull-right { float: right; }
.hidden { display: none !important; }
.mt-10 { margin-top: 10px; }
.mt-20 { margin-top: 20px; }
.mb-10 { margin-bottom: 10px; }
.mb-20 { margin-bottom: 20px; }

/* ---------- 按钮 ---------- */
.btn {
    display: inline-block;
    padding: 7px 16px;
    border: 1px solid #d9d9d9;
    border-radius: 4px;
    background: #fff;
    color: #333;
    font-size: 14px;
    line-height: 1.5;
    transition: all 0.2s;
    text-align: center;
    vertical-align: middle;
}
.btn:hover { border-color: #40a9ff; color: #40a9ff; }
.btn-primary { background: #1890ff; border-color: #1890ff; color: #fff; }
.btn-primary:hover { background: #40a9ff; border-color: #40a9ff; color: #fff; }
.btn-success { background: #52c41a; border-color: #52c41a; color: #fff; }
.btn-success:hover { background: #73d13d; border-color: #73d13d; color: #fff; }
.btn-danger { background: #ff4d4f; border-color: #ff4d4f; color: #fff; }
.btn-danger:hover { background: #ff7875; border-color: #ff7875; color: #fff; }
.btn-warning { background: #faad14; border-color: #faad14; color: #fff; }
.btn-warning:hover { background: #ffc53d; border-color: #ffc53d; color: #fff; }
.btn-sm { padding: 3px 10px; font-size: 12px; }
.btn-lg { padding: 10px 24px; font-size: 16px; }
.btn-block { display: block; width: 100%; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* ---------- 表单 ---------- */
.form-group { margin-bottom: 18px; }
.form-label { display: block; margin-bottom: 6px; font-weight: 500; color: #333; }
.form-control {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #d9d9d9;
    border-radius: 4px;
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
}
.form-control:focus { border-color: #40a9ff; box-shadow: 0 0 0 2px rgba(24,144,255,0.15); }
.form-control:disabled { background: #f5f5f5; color: #999; }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-inline { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.form-inline .form-control { width: auto; }
.form-tip { font-size: 12px; color: #999; margin-top: 4px; }

/* ---------- 卡片 ---------- */
.card {
    background: #fff;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    margin-bottom: 20px;
}
.card-header {
    padding: 14px 20px;
    border-bottom: 1px solid #f0f0f0;
    font-weight: 600;
    font-size: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.card-body { padding: 20px; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.table th, .table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid #f0f0f0;
}
.table th {
    background: #fafafa;
    font-weight: 600;
    color: #555;
    white-space: nowrap;
}
.table tbody tr:hover { background: #f5faff; }
.table .checkbox-col { width: 40px; text-align: center; }
.table .action-col { white-space: nowrap; }
.table .action-col .btn { margin-right: 4px; }
.empty-row td { text-align: center; padding: 40px; color: #999; }

/* ---------- 标签/徽章 ---------- */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
    line-height: 1.5;
}
.badge-primary { background: #e6f7ff; color: #1890ff; }
.badge-success { background: #f6ffed; color: #52c41a; }
.badge-danger  { background: #fff1f0; color: #ff4d4f; }
.badge-warning { background: #fffbe6; color: #faad14; }
.badge-default { background: #f5f5f5; color: #666; }

/* ---------- 分页 ---------- */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    margin-top: 20px;
    flex-wrap: wrap;
}
.pagination a, .pagination span {
    display: inline-block;
    padding: 5px 12px;
    border: 1px solid #d9d9d9;
    border-radius: 4px;
    color: #333;
    font-size: 13px;
    background: #fff;
}
.pagination a:hover { border-color: #1890ff; color: #1890ff; }
.pagination .active { background: #1890ff; border-color: #1890ff; color: #fff; }
.pagination .disabled { color: #ccc; cursor: not-allowed; }
.pagination .total { border: none; background: none; color: #999; }

/* ---------- 弹窗 ---------- */
.modal-mask {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.45);
    display: flex; justify-content: center; align-items: center;
    z-index: 1000;
}
.modal {
    background: #fff;
    border-radius: 8px;
    width: 480px;
    max-width: 90vw;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 6px 24px rgba(0,0,0,0.15);
}
.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid #f0f0f0;
    font-size: 16px;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.modal-close {
    background: none; border: none; font-size: 20px; color: #999;
    cursor: pointer; line-height: 1;
}
.modal-close:hover { color: #333; }
.modal-body { padding: 20px; }
.modal-footer {
    padding: 12px 20px;
    border-top: 1px solid #f0f0f0;
    text-align: right;
}
.modal-footer .btn { margin-left: 8px; }

/* ---------- Toast 提示 ---------- */
.toast-container {
    position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
    z-index: 2000; display: flex; flex-direction: column; gap: 8px;
}
.toast {
    padding: 10px 20px;
    border-radius: 4px;
    color: #fff;
    font-size: 14px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    animation: toastIn 0.3s ease;
    max-width: 400px;
}
.toast-success { background: #52c41a; }
.toast-error   { background: #ff4d4f; }
.toast-warning { background: #faad14; }
.toast-info    { background: #1890ff; }
@keyframes toastIn {
    from { opacity: 0; transform: translateY(-20px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ---------- 加载动画 ---------- */
.loading-mask {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255,255,255,0.7);
    display: flex; justify-content: center; align-items: center;
    z-index: 1500;
}
.loading-spinner {
    width: 40px; height: 40px;
    border: 3px solid #e6f7ff;
    border-top-color: #1890ff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* =====================================================
   登录页
   ===================================================== */
.login-page {
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
}
.login-box {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    width: 400px;
    max-width: 100%;
    padding: 40px 36px;
}
.login-logo {
    text-align: center;
    margin-bottom: 8px;
}
.login-logo .icon {
    width: 56px; height: 56px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 28px;
    margin-bottom: 12px;
}
.login-title {
    font-size: 22px;
    font-weight: 700;
    color: #333;
    text-align: center;
}
.login-slogan {
    text-align: center;
    color: #999;
    font-size: 13px;
    margin: 6px 0 28px;
}
.login-box .form-group { margin-bottom: 20px; }
.login-box .form-control { padding: 10px 14px; font-size: 15px; }
.login-footer {
    text-align: center;
    margin-top: 24px;
    font-size: 12px;
    color: #bbb;
}

/* =====================================================
   后台布局
   ===================================================== */
.layout { display: flex; min-height: 100vh; }

/* 侧边栏 */
.sidebar {
    width: 220px;
    background: #001529;
    color: rgba(255,255,255,0.65);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
}
.sidebar-logo {
    padding: 18px 20px;
    font-size: 16px;
    font-weight: 700;
    color: #fff;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    gap: 10px;
}
.sidebar-logo .icon {
    width: 32px; height: 32px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 16px;
}
.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 24px;
    color: rgba(255,255,255,0.65);
    font-size: 14px;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}
.sidebar-nav a:hover { color: #fff; background: rgba(255,255,255,0.06); }
.sidebar-nav a.active {
    color: #fff;
    background: #1890ff;
    border-left-color: #fff;
}
.sidebar-nav .nav-icon { font-size: 16px; width: 20px; text-align: center; }
.sidebar-nav .nav-group-title {
    padding: 12px 24px 6px;
    font-size: 12px;
    color: rgba(255,255,255,0.35);
    text-transform: uppercase;
}

/* 主内容区 */
.main {
    flex: 1;
    margin-left: 220px;
    display: flex;
    flex-direction: column;
    min-width: 0;
}
/* 顶部栏 */
.topbar {
    height: 56px;
    background: #fff;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 50;
}
.topbar-title { font-size: 16px; font-weight: 600; color: #333; }
.topbar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    position: relative;
}
.topbar-user .avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
}
.topbar-user .username { font-size: 14px; color: #333; }
.topbar-user .role-tag {
    font-size: 11px;
    padding: 1px 6px;
    border-radius: 3px;
    background: #e6f7ff;
    color: #1890ff;
}
.user-dropdown {
    position: absolute;
    top: 100%; right: 0;
    background: #fff;
    border-radius: 6px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    min-width: 140px;
    padding: 6px 0;
    display: none;
    z-index: 200;
}
.user-dropdown.show { display: block; }
.user-dropdown a {
    display: block;
    padding: 8px 16px;
    color: #333;
    font-size: 13px;
}
.user-dropdown a:hover { background: #f5faff; color: #1890ff; }

/* 内容区 */
.content { padding: 20px 24px; flex: 1; }
.page-header {
    margin-bottom: 20px;
}
.page-header h2 { font-size: 20px; font-weight: 600; color: #333; }
.page-header .breadcrumb { font-size: 13px; color: #999; margin-top: 4px; }

/* =====================================================
   仪表盘统计卡片
   ===================================================== */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}
.stat-card {
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    display: flex;
    align-items: center;
    gap: 16px;
}
.stat-card .stat-icon {
    width: 48px; height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: #fff;
    flex-shrink: 0;
}
.stat-card .stat-icon.blue   { background: linear-gradient(135deg, #1890ff, #36cfc9); }
.stat-card .stat-icon.green  { background: linear-gradient(135deg, #52c41a, #95de64); }
.stat-card .stat-icon.orange { background: linear-gradient(135deg, #fa8c16, #ffc53d); }
.stat-card .stat-icon.purple { background: linear-gradient(135deg, #722ed1, #b37feb); }
.stat-card .stat-icon.red    { background: linear-gradient(135deg, #ff4d4f, #ff7875); }
.stat-card .stat-info .stat-value {
    font-size: 24px;
    font-weight: 700;
    color: #333;
    line-height: 1.2;
}
.stat-card .stat-info .stat-label {
    font-size: 13px;
    color: #999;
    margin-top: 4px;
}

/* 图表区域 */
.chart-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 16px;
}
@media (max-width: 900px) {
    .chart-grid { grid-template-columns: 1fr; }
}
.chart-box {
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.chart-box h3 { font-size: 15px; font-weight: 600; margin-bottom: 16px; color: #333; }
.bar-chart { display: flex; align-items: flex-end; gap: 12px; height: 200px; padding-top: 10px; }
.bar-chart .bar-item { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bar-chart .bar {
    width: 100%;
    max-width: 36px;
    background: linear-gradient(180deg, #1890ff, #69c0ff);
    border-radius: 4px 4px 0 0;
    transition: height 0.5s ease;
    position: relative;
}
.bar-chart .bar:hover { background: linear-gradient(180deg, #40a9ff, #91d5ff); }
.bar-chart .bar-value { font-size: 11px; color: #666; }
.bar-chart .bar-label { font-size: 11px; color: #999; }

/* 类型分布 */
.type-list .type-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid #f5f5f5;
}
.type-list .type-item:last-child { border-bottom: none; }
.type-list .type-name { display: flex; align-items: center; gap: 8px; }
.type-list .type-dot { width: 10px; height: 10px; border-radius: 50%; }
.type-list .type-count { font-weight: 600; color: #333; }

/* =====================================================
   上传页面
   ===================================================== */
.upload-area {
    border: 2px dashed #d9d9d9;
    border-radius: 8px;
    padding: 50px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    background: #fafafa;
}
.upload-area:hover, .upload-area.dragover {
    border-color: #1890ff;
    background: #f0f7ff;
}
.upload-area .upload-icon {
    font-size: 48px;
    color: #1890ff;
    margin-bottom: 12px;
}
.upload-area .upload-text { font-size: 16px; color: #333; margin-bottom: 6px; }
.upload-area .upload-hint { font-size: 13px; color: #999; }
.upload-area input[type="file"] { display: none; }

/* 上传队列 */
.upload-queue { margin-top: 20px; }
.upload-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: #fff;
    border-radius: 6px;
    margin-bottom: 8px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.upload-item .file-icon {
    width: 36px; height: 36px;
    border-radius: 6px;
    background: #e6f7ff;
    color: #1890ff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}
.upload-item .file-info { flex: 1; min-width: 0; }
.upload-item .file-name {
    font-size: 14px;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.upload-item .file-size { font-size: 12px; color: #999; }
.upload-item .progress-wrap {
    width: 120px;
    flex-shrink: 0;
}
.upload-item .progress-bar {
    height: 6px;
    background: #f0f0f0;
    border-radius: 3px;
    overflow: hidden;
}
.upload-item .progress-fill {
    height: 100%;
    background: #1890ff;
    border-radius: 3px;
    transition: width 0.3s;
}
/* 进度达到90%（已传完，正在转存云端）时的等待动画 */
.upload-item .progress-fill.progress-waiting {
    background: linear-gradient(90deg, #1890ff 25%, #69c0ff 50%, #1890ff 75%);
    background-size: 200% 100%;
    animation: progressWaiting 1.2s linear infinite;
}
@keyframes progressWaiting {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
.upload-item .progress-text { font-size: 11px; color: #999; text-align: center; margin-top: 2px; }
.upload-item .status-icon { font-size: 18px; flex-shrink: 0; width: 24px; text-align: center; }
.upload-item .status-success { color: #52c41a; }
.upload-item .status-error { color: #ff4d4f; }
.upload-item .status-uploading { color: #1890ff; }

/* =====================================================
   筛选栏
   ===================================================== */
.filter-bar {
    background: #fff;
    border-radius: 6px;
    padding: 14px 20px;
    margin-bottom: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}
.filter-bar .form-control { width: 160px; }
.filter-bar .filter-label { color: #666; font-size: 13px; }

/* =====================================================
   预览弹窗
   ===================================================== */
.preview-modal .modal { width: 800px; }
.preview-content {
    max-height: 70vh;
    overflow: auto;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}
.preview-content img { max-width: 100%; border-radius: 4px; }
.preview-content iframe { width: 100%; height: 65vh; border: none; border-radius: 4px; }
.preview-content video { max-width: 100%; border-radius: 4px; }
.preview-content pre {
    width: 100%;
    padding: 16px;
    background: #f6f8fa;
    border-radius: 4px;
    font-size: 13px;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 65vh;
    overflow: auto;
}

/* =====================================================
   响应式
   ===================================================== */
@media (max-width: 768px) {
    .sidebar { width: 60px; }
    .sidebar-logo span, .sidebar-nav a span:not(.nav-icon) { display: none; }
    .sidebar-nav a { justify-content: center; padding: 12px; }
    .main { margin-left: 60px; }
    .content { padding: 12px; }
    .stat-grid { grid-template-columns: 1fr 1fr; }
    .filter-bar .form-control { width: 100%; }
}

/* ---------- 侧边栏子菜单 ---------- */
.nav-submenu { margin-bottom: 4px; }
.nav-submenu-title {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    color: rgba(255,255,255,0.7);
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s;
    user-select: none;
}
.nav-submenu-title:hover { background: rgba(255,255,255,0.08); color: #fff; }
.nav-submenu-title .nav-icon { margin-right: 10px; font-size: 16px; }
.nav-arrow {
    margin-left: auto;
    font-size: 10px;
    transition: transform 0.2s;
    opacity: 0.6;
}
.nav-submenu.open .nav-arrow { transform: rotate(90deg); }
.nav-submenu-items {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}
.nav-submenu.open .nav-submenu-items { max-height: 300px; }
.nav-submenu-items a {
    padding-left: 42px !important;
    font-size: 13px;
}

/* ---------- 配置页面标签切换 ---------- */
.settings-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    border-bottom: 2px solid #e8e8e8;
    padding-bottom: 0;
}
.settings-tabs .tab {
    padding: 10px 20px;
    color: #666;
    text-decoration: none;
    border-radius: 6px 6px 0 0;
    font-size: 14px;
    transition: all 0.2s;
    margin-bottom: -2px;
    border-bottom: 2px solid transparent;
}
.settings-tabs .tab:hover { color: #667eea; background: #f5f5ff; }
.settings-tabs .tab.active {
    color: #667eea;
    border-bottom-color: #667eea;
    font-weight: 600;
    background: #f5f5ff;
}
