/* ========== 基础重置 ========== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --accent: #06b6d4;
    --gradient: linear-gradient(135deg, #6366f1 0%, #06b6d4 100%);
    --gradient-hover: linear-gradient(135deg, #4f46e5 0%, #0891b2 100%);
    --bg: #f1f5f9;
    --bg-dark: #0f172a;
    --card: #ffffff;
    --text: #1e293b;
    --text-light: #64748b;
    --text-lighter: #94a3b8;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
    --shadow-lg: 0 10px 25px -5px rgba(0,0,0,0.08), 0 8px 10px -6px rgba(0,0,0,0.04);
    --shadow-xl: 0 20px 40px -10px rgba(99,102,241,0.15);
    --radius: 12px;
    --radius-lg: 16px;
    --radius-sm: 8px;
}

html { scroll-behavior: smooth; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--primary-dark); }

img { max-width: 100%; display: block; }

/* ========== 顶部导航 ========== */
.navbar {
    background: rgba(255,255,255,0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
    position: sticky;
    top: 0;
    z-index: 100;
}
.navbar .logo {
    font-size: 20px;
    font-weight: 700;
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    display: flex;
    align-items: center;
    gap: 8px;
}
.navbar .logo::before {
    content: '';
    width: 28px;
    height: 28px;
    background: var(--gradient);
    border-radius: 8px;
    display: inline-block;
    -webkit-text-fill-color: initial;
}
.nav-links { display: flex; gap: 8px; align-items: center; }
.nav-links a {
    color: var(--text-light);
    font-size: 14px;
    font-weight: 500;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}
.nav-links a:hover {
    color: var(--primary);
    background: rgba(99,102,241,0.08);
    text-decoration: none;
}
.nav-links span {
    color: var(--text-light);
    font-size: 14px;
}

/* ========== 容器 ========== */
.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 32px 24px;
}
.container-sm {
    max-width: 440px;
    margin: 0 auto;
    padding: 48px 24px;
}

/* ========== 卡片 ========== */
.card {
    background: var(--card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 32px;
    margin-bottom: 24px;
    border: 1px solid var(--border-light);
    transition: box-shadow 0.3s;
}
.card:hover { box-shadow: var(--shadow-lg); }
.card h2 {
    margin-bottom: 24px;
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
}
.card h3 {
    margin-bottom: 16px;
    font-size: 17px;
    font-weight: 600;
}

/* ========== 表单 ========== */
.form-group { margin-bottom: 20px; }
.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 14px;
    color: var(--text);
}
.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="email"],
.form-group input[type="number"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    transition: all 0.2s;
    background: var(--card);
    color: var(--text);
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.12);
}

/* ========== 按钮 ========== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 11px 22px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s;
    text-align: center;
    white-space: nowrap;
}
.btn-primary {
    background: var(--gradient);
    color: #fff;
    box-shadow: 0 4px 14px rgba(99,102,241,0.3);
}
.btn-primary:hover {
    background: var(--gradient-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(99,102,241,0.4);
    text-decoration: none;
    color: #fff;
}
.btn-danger {
    background: var(--danger);
    color: #fff;
}
.btn-danger:hover { background: #dc2626; text-decoration: none; color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #059669; text-decoration: none; color: #fff; }
.btn-secondary {
    background: var(--border-light);
    color: var(--text-light);
}
.btn-secondary:hover {
    background: var(--border);
    color: var(--text);
    text-decoration: none;
}
.btn-sm { padding: 6px 14px; font-size: 13px; }

/* ========== 上传区域 ========== */
.upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 60px 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    position: relative;
    overflow: hidden;
}
.upload-area::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(99,102,241,0.05) 0%, transparent 60%);
    opacity: 0;
    transition: opacity 0.3s;
}
.upload-area:hover, .upload-area.dragover {
    border-color: var(--primary);
    background: linear-gradient(135deg, #eef2ff 0%, #ecfeff 100%);
    transform: scale(1.01);
}
.upload-area:hover::before, .upload-area.dragover::before { opacity: 1; }
.upload-area .upload-icon {
    width: 72px;
    height: 72px;
    margin: 0 auto 16px;
    background: var(--gradient);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    box-shadow: 0 8px 24px rgba(99,102,241,0.25);
    position: relative;
}
.upload-area p { color: var(--text-light); margin-top: 8px; font-size: 15px; }
.upload-area p.small { font-size: 13px; color: var(--text-lighter); }
.upload-area input[type="file"] { display: none; }

/* ========== 图片网格 ========== */
.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
    margin-top: 24px;
}
.image-item {
    background: var(--card);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
    transition: all 0.3s;
}
.image-item:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}
.image-item .img-wrap {
    position: relative;
    width: 100%;
    padding-top: 75%;
    overflow: hidden;
    background: var(--border-light);
}
.image-item .img-wrap img {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s;
}
.image-item:hover .img-wrap img { transform: scale(1.05); }
.image-item .info {
    padding: 14px;
    font-size: 13px;
    color: var(--text-light);
}
.image-item .info .name {
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}
.image-item .actions {
    padding: 10px 14px;
    border-top: 1px solid var(--border-light);
    display: flex;
    gap: 8px;
}

/* ========== 表格 ========== */
.table-wrap { overflow-x: auto; }
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    min-width: 600px;
}
table th, table td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
}
table th {
    background: var(--border-light);
    font-weight: 600;
    color: var(--text-light);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
table tr { transition: background 0.2s; }
table tbody tr:hover { background: var(--border-light); }
table img {
    width: 52px;
    height: 52px;
    object-fit: cover;
    border-radius: var(--radius-sm);
}

/* ========== 提示消息 ========== */
.alert {
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-size: 14px;
    font-weight: 500;
    border: none;
}
.alert-success {
    background: #ecfdf5;
    color: #065f46;
    border-left: 4px solid var(--success);
}
.alert-error {
    background: #fef2f2;
    color: #991b1b;
    border-left: 4px solid var(--danger);
}
.alert-info {
    background: #eff6ff;
    color: #1e40af;
    border-left: 4px solid var(--primary);
}

/* ========== 统计卡片 ========== */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}
.stat-card {
    background: var(--card);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-light);
    position: relative;
    overflow: hidden;
    transition: all 0.3s;
}
.stat-card::after {
    content: '';
    position: absolute;
    top: 0; right: 0;
    width: 80px; height: 80px;
    background: var(--gradient);
    opacity: 0.06;
    border-radius: 0 0 0 80px;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.stat-card .number {
    font-size: 34px;
    font-weight: 800;
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.stat-card .label {
    font-size: 14px;
    color: var(--text-light);
    margin-top: 4px;
    font-weight: 500;
}

/* ========== 分页 ========== */
.pagination {
    display: flex;
    gap: 6px;
    justify-content: center;
    margin-top: 28px;
    flex-wrap: wrap;
}
.pagination a, .pagination span {
    padding: 8px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    color: var(--text-light);
}
.pagination a:hover {
    border-color: var(--primary);
    color: var(--primary);
    text-decoration: none;
}
.pagination .current {
    background: var(--gradient);
    color: #fff;
    border-color: transparent;
}

/* ========== 页脚 ========== */
.footer {
    text-align: center;
    padding: 36px 24px;
    color: var(--text-lighter);
    font-size: 13px;
}

/* ========== 链接复制框 ========== */
.link-box {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}
.link-box input {
    flex: 1;
    padding: 9px 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    background: var(--border-light);
    color: var(--text);
    min-width: 0;
}

/* ========== 后台布局 ========== */
.admin-layout {
    display: flex;
    min-height: calc(100vh - 64px);
}
.admin-sidebar {
    width: 220px;
    background: var(--bg-dark);
    padding: 20px 12px;
    flex-shrink: 0;
    transition: transform 0.3s;
}
.admin-sidebar a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    color: #94a3b8;
    font-size: 14px;
    font-weight: 500;
    border-radius: var(--radius-sm);
    margin-bottom: 4px;
    transition: all 0.2s;
}
.admin-sidebar a:hover {
    background: rgba(255,255,255,0.06);
    color: #fff;
    text-decoration: none;
}
.admin-sidebar a.active {
    background: var(--gradient);
    color: #fff;
    box-shadow: 0 4px 12px rgba(99,102,241,0.3);
}
.admin-sidebar a::before {
    content: '';
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.5;
}
.admin-content {
    flex: 1;
    padding: 28px;
    min-width: 0;
    overflow-x: hidden;
}
.admin-content h2 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 24px;
}

/* 移动端菜单按钮 */
.menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text);
    padding: 4px 8px;
}

/* ========== 开关 ========== */
.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
    flex-shrink: 0;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #cbd5e1;
    border-radius: 26px;
    transition: 0.3s;
}
.slider:before {
    content: "";
    position: absolute;
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background: #fff;
    border-radius: 50%;
    transition: 0.3s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.switch input:checked + .slider { background: var(--gradient); }
.switch input:checked + .slider:before { transform: translateX(24px); }

/* ========== 上传成功预览 ========== */
.upload-result {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 24px;
    border: 1px solid var(--border-light);
}
.upload-result img {
    max-height: 320px;
    border-radius: var(--radius-sm);
    margin: 0 auto 16px;
    box-shadow: var(--shadow);
}

/* ========== 搜索栏 ========== */
.search-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    align-items: flex-end;
}
.search-bar input, .search-bar select {
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    flex: 1;
    min-width: 160px;
}
.search-bar input:focus, .search-bar select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.12);
}

/* ========== 响应式 ========== */
@media (max-width: 768px) {
    .navbar { padding: 0 16px; height: 56px; }
    .navbar .logo { font-size: 17px; }
    .nav-links { gap: 4px; }
    .nav-links a { padding: 6px 10px; font-size: 13px; }
    .nav-links span { display: none; }

    .container { padding: 20px 16px; }
    .container-sm { padding: 32px 16px; }
    .card { padding: 20px; }
    .card h2 { font-size: 19px; }

    .upload-area { padding: 40px 16px; }
    .upload-area .upload-icon { width: 56px; height: 56px; font-size: 28px; border-radius: 16px; }

    .image-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
    .image-item .info { padding: 10px; font-size: 12px; }
    .image-item .actions { padding: 8px 10px; }

    /* 后台移动端 */
    .menu-toggle { display: block; }
    .admin-sidebar {
        position: fixed;
        left: 0; top: 56px; bottom: 0;
        z-index: 99;
        transform: translateX(-100%);
        box-shadow: 4px 0 20px rgba(0,0,0,0.15);
    }
    .admin-sidebar.open { transform: translateX(0); }
    .admin-content { padding: 20px 16px; }
    .admin-content h2 { font-size: 20px; }

    .stats { grid-template-columns: 1fr 1fr; gap: 12px; }
    .stat-card { padding: 16px; }
    .stat-card .number { font-size: 26px; }

    .search-bar .form-group { flex: 1 1 100%; }
    .btn { padding: 10px 16px; font-size: 13px; }
}

@media (max-width: 480px) {
    .image-grid { grid-template-columns: 1fr 1fr; }
    .stats { grid-template-columns: 1fr; }
    .navbar { padding: 0 10px; }
    .navbar .logo { font-size: 15px; }
    .nav-links { gap: 2px; }
    .nav-links a { padding: 5px 7px; font-size: 12px; }
}

/* 侧边栏遮罩 */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 56px; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4);
    z-index: 98;
}
.sidebar-overlay.show { display: block; }
