/* ===================================================================
   文档素材下载小程序 - 后台管理样式
   =================================================================== */

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
                 "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    background: #f3f4f6;
    color: #1f2937;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: #1f7cff; text-decoration: none; }
a:hover { text-decoration: underline; }

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

.sidebar {
    width: 220px; background: #0f172a; color: #cbd5e1;
    flex-shrink: 0; padding: 0; position: sticky; top: 0; height: 100vh;
    overflow-y: auto;
}
.sidebar-brand {
    padding: 22px 20px; color: #fff; font-size: 16px; font-weight: 600;
    border-bottom: 1px solid #1e293b; letter-spacing: .5px;
}
.sidebar-brand .brand-sub {
    display: block; font-size: 11px; color: #64748b; font-weight: 400; margin-top: 4px;
}
.nav-group { padding: 12px 0; }
.nav-item {
    display: flex; align-items: center; padding: 10px 20px;
    color: #cbd5e1; font-size: 14px; cursor: pointer; transition: all .15s;
    border-left: 3px solid transparent;
}
.nav-item:hover { background: #1e293b; color: #fff; }
.nav-item.active {
    background: #1e293b; color: #fff;
    border-left-color: #1f7cff;
}
.nav-item .icon {
    display: inline-block; width: 18px; height: 18px; margin-right: 10px;
    text-align: center; line-height: 18px; font-size: 14px;
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    background: #fff; padding: 14px 28px;
    display: flex; justify-content: space-between; align-items: center;
    border-bottom: 1px solid #e5e7eb; position: sticky; top: 0; z-index: 10;
}
.topbar h1 { font-size: 17px; font-weight: 600; }
.topbar-user { display: flex; align-items: center; gap: 14px; font-size: 13px; color: #6b7280; }
.topbar-user .username {
    background: #eef2ff; color: #4338ca; padding: 4px 10px;
    border-radius: 12px; font-weight: 500;
}
.btn-logout {
    padding: 5px 12px; background: #fee2e2; color: #b91c1c;
    border: none; border-radius: 5px; cursor: pointer; font-size: 12px;
}
.btn-logout:hover { background: #fecaca; }

.content { padding: 24px 28px; flex: 1; }

/* ---------- 卡片 / 面板 ---------- */
.card {
    background: #fff; border-radius: 8px; padding: 20px 24px;
    box-shadow: 0 1px 3px rgba(0,0,0,.06); margin-bottom: 18px;
}
.card-title {
    font-size: 15px; font-weight: 600; margin-bottom: 16px;
    display: flex; justify-content: space-between; align-items: center;
}

/* ---------- 统计卡片 ---------- */
.stats-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px; margin-bottom: 22px;
}
.stat-card {
    background: #fff; border-radius: 8px; padding: 18px 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
    display: flex; align-items: center; gap: 14px;
}
.stat-card .stat-icon {
    width: 48px; height: 48px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px; color: #fff;
}
.stat-card .stat-icon.blue { background: linear-gradient(135deg, #3b82f6, #1d4ed8); }
.stat-card .stat-icon.green { background: linear-gradient(135deg, #10b981, #047857); }
.stat-card .stat-icon.orange { background: linear-gradient(135deg, #f59e0b, #d97706); }
.stat-card .stat-icon.purple { background: linear-gradient(135deg, #8b5cf6, #6d28d9); }
.stat-card .stat-info .stat-label { font-size: 12px; color: #6b7280; margin-bottom: 4px; }
.stat-card .stat-info .stat-value { font-size: 24px; font-weight: 600; color: #111827; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
table.data-table {
    width: 100%; border-collapse: collapse; font-size: 13px;
}
.data-table th, .data-table td {
    padding: 11px 14px; text-align: left;
    border-bottom: 1px solid #f3f4f6;
}
.data-table th {
    background: #f9fafb; color: #6b7280; font-weight: 500;
    font-size: 12px; text-transform: uppercase; letter-spacing: .3px;
}
.data-table tbody tr:hover { background: #f9fafb; }
.data-table .cell-title { font-weight: 500; color: #111827; }
.data-table .cell-muted { color: #6b7280; }

/* ---------- 标签 / 徽章 ---------- */
.tag {
    display: inline-block; padding: 2px 8px; border-radius: 4px;
    font-size: 12px; background: #e0e7ff; color: #3730a3;
}
.tag-green { background: #d1fae5; color: #065f46; }
.tag-red { background: #fee2e2; color: #991b1b; }
.tag-orange { background: #ffedd5; color: #9a3412; }
.tag-gray { background: #f3f4f6; color: #4b5563; }

/* ---------- 按钮 ---------- */
.btn {
    display: inline-block; padding: 7px 14px; border: none; border-radius: 5px;
    font-size: 13px; cursor: pointer; transition: all .15s; line-height: 1.4;
    text-decoration: none; vertical-align: middle;
}
.btn-primary { background: #1f7cff; color: #fff; }
.btn-primary:hover { background: #196bf3; }
.btn-success { background: #10b981; color: #fff; }
.btn-success:hover { background: #059669; }
.btn-warning { background: #f59e0b; color: #fff; }
.btn-warning:hover { background: #d97706; }
.btn-danger { background: #ef4444; color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-default {
    background: #fff; color: #374151; border: 1px solid #d1d5db;
}
.btn-default:hover { background: #f9fafb; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-link {
    background: transparent; color: #1f7cff; padding: 4px 8px;
    border: none; cursor: pointer; font-size: 13px;
}
.btn-link:hover { text-decoration: underline; }
.btn-link.danger { color: #ef4444; }

/* ---------- 表单 ---------- */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block; font-size: 13px; color: #374151;
    margin-bottom: 6px; font-weight: 500;
}
.form-group label .required { color: #ef4444; }
input[type="text"], input[type="password"], input[type="number"],
input[type="url"], select, textarea {
    width: 100%; padding: 8px 12px; border: 1px solid #d1d5db;
    border-radius: 5px; font-size: 14px; font-family: inherit;
    transition: border-color .15s; background: #fff;
}
input:focus, select:focus, textarea:focus {
    outline: none; border-color: #1f7cff;
    box-shadow: 0 0 0 3px rgba(31,124,255,.1);
}
textarea { resize: vertical; min-height: 80px; }
.form-row { display: flex; gap: 14px; }
.form-row .form-group { flex: 1; }
.form-actions { display: flex; gap: 10px; margin-top: 20px; }

/* ---------- 工具栏 ---------- */
.toolbar {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 16px; flex-wrap: wrap; gap: 10px;
}
.toolbar-left { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.toolbar-right { display: flex; gap: 10px; align-items: center; }

.search-box {
    display: flex; border: 1px solid #d1d5db; border-radius: 5px; overflow: hidden;
}
.search-box input { border: none; padding: 7px 12px; width: 240px; }
.search-box input:focus { box-shadow: none; }
.search-box button {
    border: none; padding: 7px 14px; background: #f3f4f6;
    cursor: pointer; font-size: 13px;
}
.search-box button:hover { background: #e5e7eb; }

/* ---------- 提示 ---------- */
.alert { padding: 11px 14px; border-radius: 5px; margin-bottom: 16px; font-size: 13px; }
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.alert-info { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }

/* ---------- 分页 ---------- */
.pagination {
    display: flex; justify-content: space-between; align-items: center;
    margin-top: 16px; font-size: 13px; color: #6b7280;
}
.pagination .pages { display: flex; gap: 4px; }
.pagination a, .pagination span {
    display: inline-block; padding: 5px 10px; border-radius: 4px;
    border: 1px solid #e5e7eb; color: #374151; background: #fff;
}
.pagination a:hover { background: #f3f4f6; text-decoration: none; }
.pagination .current {
    background: #1f7cff; color: #fff; border-color: #1f7cff;
}

/* ---------- 登录页 ---------- */
.login-page {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); padding: 20px;
}
.login-card {
    width: 100%; max-width: 380px; background: #fff; border-radius: 12px;
    padding: 36px 32px; box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.login-card h1 { font-size: 22px; margin-bottom: 6px; text-align: center; color: #111827; }
.login-card .sub { font-size: 13px; color: #6b7280; text-align: center; margin-bottom: 28px; }
.login-card .btn { width: 100%; padding: 11px; font-size: 14px; }

/* ---------- 模态框 ---------- */
.modal-mask {
    position: fixed; inset: 0; background: rgba(0,0,0,.5);
    display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal {
    background: #fff; border-radius: 8px; width: 90%; max-width: 600px;
    max-height: 90vh; overflow-y: auto;
}
.modal-head {
    padding: 16px 24px; border-bottom: 1px solid #e5e7eb;
    display: flex; justify-content: space-between; align-items: center;
}
.modal-head h3 { font-size: 16px; font-weight: 600; }
.modal-body { padding: 24px; }
.modal-foot {
    padding: 14px 24px; border-top: 1px solid #e5e7eb;
    display: flex; justify-content: flex-end; gap: 10px;
}

/* ---------- 空状态 ---------- */
.empty {
    text-align: center; padding: 40px 20px; color: #9ca3af; font-size: 13px;
}

/* ---------- 链接组 ---------- */
.link-item {
    padding: 10px 12px; background: #f9fafb; border-radius: 6px;
    margin-bottom: 8px; font-size: 13px;
}
.link-item .link-url {
    color: #6b7280; word-break: break-all; margin: 4px 0; font-family: monospace;
}

/* ---------- 响应式 ---------- */
@media (max-width: 768px) {
    .sidebar { display: none; }
    .content { padding: 16px; }
    .toolbar { flex-direction: column; align-items: stretch; }
    .form-row { flex-direction: column; }
}
