/* ============================================
   图床系统 - 主样式表
   ============================================ */

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --primary: #4f6ef7;
    --primary-dark: #3a56d4;
    --secondary: #6c757d;
    --success: #28a745;
    --danger: #dc3545;
    --warning: #ffc107;
    --info: #17a2b8;
    --light: #f8f9fa;
    --dark: #343a40;
    --border: #dee2e6;
    --shadow: 0 2px 12px rgba(0,0,0,.08);
    --radius: 10px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background: #f0f2f5;
    color: #333;
    min-height: 100vh;
}

/* ---- 导航栏 ---- */
.navbar {
    background: linear-gradient(135deg, #4f6ef7 0%, #6a4fef 100%);
    padding: 0 24px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 8px rgba(79,110,247,.3);
    position: sticky;
    top: 0;
    z-index: 100;
}
.navbar-brand {
    color: #fff;
    font-size: 20px;
    font-weight: 700;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
}
.navbar-nav {
    display: flex;
    gap: 8px;
    align-items: center;
}
.navbar-nav a {
    color: rgba(255,255,255,.85);
    text-decoration: none;
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 14px;
    transition: all .2s;
}
.navbar-nav a:hover, .navbar-nav a.active {
    background: rgba(255,255,255,.2);
    color: #fff;
}

/* ---- 容器 ---- */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px 16px;
}

/* ---- 搜索区 ---- */
.search-bar {
    background: #fff;
    border-radius: var(--radius);
    padding: 20px 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 0;
    align-items: center;
}
.search-bar input[type=text],
.search-bar select {
    height: 40px;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0 12px;
    font-size: 14px;
    outline: none;
    transition: border .2s;
}
.search-bar input[type=text] { flex: 1; min-width: 200px; }
.search-bar input[type=text]:focus,
.search-bar select:focus { border-color: var(--primary); }

/* ---- 按钮 ---- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    transition: all .2s;
    white-space: nowrap;
}
.btn-primary   { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success   { background: var(--success); color: #fff; }
.btn-success:hover { background: #218838; }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-danger:hover  { background: #c82333; }
.btn-warning   { background: var(--warning); color: #333; }
.btn-warning:hover { background: #e0a800; }
.btn-secondary { background: var(--secondary); color: #fff; }
.btn-secondary:hover { background: #5a6268; }
.btn-outline   { background: transparent; border: 1px solid var(--primary); color: var(--primary); }
.btn-outline:hover { background: var(--primary); color: #fff; }
.btn-sm { padding: 5px 12px; font-size: 13px; }

/* ---- 图片网格 ---- */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}

.card {
    background: #fff;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: transform .2s, box-shadow .2s;
    cursor: pointer;
    position: relative;
}
.card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0,0,0,.12);
}
.card-thumb {
    width: 100%;
    height: 160px;
    object-fit: cover;
    display: block;
    background: #f0f2f5;
}
.card-thumb-placeholder {
    width: 100%;
    height: 160px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
}
.card-body {
    padding: 10px 12px;
}
.card-title {
    font-size: 13px;
    font-weight: 600;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}
.card-meta {
    font-size: 11px;
    color: #999;
    display: flex;
    justify-content: space-between;
}
.card-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0,0,0,.55);
    color: #fff;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 20px;
}

/* ---- 分类标签 ---- */
.category-tabs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}
.category-tab {
    padding: 6px 16px;
    border-radius: 20px;
    background: #fff;
    border: 1px solid var(--border);
    font-size: 13px;
    cursor: pointer;
    text-decoration: none;
    color: #555;
    transition: all .2s;
}
.category-tab:hover, .category-tab.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

/* ---- 分页 ---- */
.pagination {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: 32px;
    flex-wrap: wrap;
}
.pagination a, .pagination span {
    padding: 6px 14px;
    border-radius: 6px;
    border: 1px solid var(--border);
    color: #555;
    text-decoration: none;
    font-size: 13px;
    background: #fff;
    transition: all .2s;
}
.pagination a:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination .current { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ---- 灯箱 ---- */
.lightbox-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.88);
    z-index: 9999;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}
.lightbox-overlay.active { display: flex; }
.lightbox-img {
    max-width: 90vw;
    max-height: 80vh;
    border-radius: 8px;
    box-shadow: 0 0 40px rgba(0,0,0,.5);
    object-fit: contain;
}
.lightbox-close {
    position: absolute;
    top: 20px;
    right: 28px;
    color: #fff;
    font-size: 32px;
    cursor: pointer;
    line-height: 1;
    opacity: .8;
    transition: opacity .2s;
}
.lightbox-close:hover { opacity: 1; }
.lightbox-actions {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}
.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    color: #fff;
    font-size: 40px;
    cursor: pointer;
    opacity: .7;
    transition: opacity .2s;
    user-select: none;
    padding: 0 12px;
}
.lightbox-nav:hover { opacity: 1; }
.lightbox-prev { left: 10px; }
.lightbox-next { right: 10px; }
.lightbox-info {
    color: rgba(255,255,255,.7);
    font-size: 13px;
    margin-top: 8px;
}

/* ---- 上传区 ---- */
.upload-zone {
    border: 2px dashed var(--primary);
    border-radius: var(--radius);
    padding: 40px 24px;
    text-align: center;
    background: rgba(79,110,247,.04);
    transition: all .2s;
    cursor: pointer;
}
.upload-zone.dragover {
    background: rgba(79,110,247,.1);
    border-color: var(--primary-dark);
}
.upload-zone .upload-icon { font-size: 48px; margin-bottom: 12px; }
.upload-zone p { color: #666; font-size: 14px; margin-bottom: 6px; }
.upload-zone small { color: #999; }

/* ---- 表格 ---- */
.table-wrap { overflow-x: auto; }
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
thead th {
    background: #f8f9fa;
    padding: 10px 14px;
    text-align: left;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
    font-weight: 600;
}
tbody td {
    padding: 10px 14px;
    border-bottom: 1px solid #f0f0f0;
    vertical-align: middle;
}
tbody tr:hover { background: #fafbff; }

/* ---- 后台侧边栏 ---- */
.admin-layout {
    display: flex;
    min-height: calc(100vh - 60px);
}
.sidebar {
    width: 220px;
    background: #fff;
    box-shadow: 2px 0 8px rgba(0,0,0,.05);
    flex-shrink: 0;
    padding: 16px 0;
}
.sidebar-item {
    display: block;
    padding: 10px 20px;
    text-decoration: none;
    color: #555;
    font-size: 14px;
    border-left: 3px solid transparent;
    transition: all .2s;
}
.sidebar-item:hover, .sidebar-item.active {
    background: rgba(79,110,247,.08);
    color: var(--primary);
    border-left-color: var(--primary);
}
.sidebar-item .icon { margin-right: 8px; }
.sidebar-group {
    padding: 8px 20px 4px;
    font-size: 11px;
    font-weight: 700;
    color: #aaa;
    text-transform: uppercase;
    letter-spacing: .5px;
}
.admin-main {
    flex: 1;
    padding: 24px;
    overflow: hidden;
}

/* ---- 面板/卡片 ---- */
.panel {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.panel-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.panel-header h3 { font-size: 16px; font-weight: 700; }
.panel-body { padding: 20px; }

/* ---- 表单 ---- */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: #444; }
.form-control {
    width: 100%;
    height: 38px;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0 12px;
    font-size: 14px;
    outline: none;
    transition: border .2s;
}
.form-control:focus { border-color: var(--primary); }
textarea.form-control { height: auto; padding: 10px 12px; resize: vertical; }

/* ---- 提示信息 ---- */
.alert {
    padding: 12px 16px;
    border-radius: 6px;
    font-size: 14px;
    margin-bottom: 16px;
}
.alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.alert-danger  { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.alert-info    { background: #d1ecf1; color: #0c5460; border: 1px solid #bee5eb; }

/* ---- 统计卡片 ---- */
.stat-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 16px;
}
.stat-icon { font-size: 32px; }
.stat-num { font-size: 26px; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 12px; color: #999; }

/* ---- 响应式 ---- */
@media (max-width: 768px) {
    .admin-layout { flex-direction: column; }
    .sidebar { width: 100%; padding: 8px 0; display: flex; overflow-x: auto; }
    .sidebar-item { white-space: nowrap; border-left: none; border-bottom: 3px solid transparent; }
    .sidebar-item.active { border-bottom-color: var(--primary); border-left-color: transparent; }
    .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}

/* ---- 图片缩略图空状态 ---- */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #aaa;
}
.empty-state .empty-icon { font-size: 64px; margin-bottom: 16px; }
.empty-state p { font-size: 15px; }

/* ---- 进度条 ---- */
.progress-bar-wrap { background: #e9ecef; border-radius: 4px; height: 6px; margin-top: 8px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--primary); border-radius: 4px; transition: width .3s; }

/* ---- 文件类型标签 ---- */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}
.badge-img  { background: #cce5ff; color: #004085; }
.badge-pdf  { background: #f8d7da; color: #721c24; }
.badge-doc  { background: #cce5ff; color: #004085; }
.badge-xls  { background: #d4edda; color: #155724; }
.badge-txt  { background: #e2e3e5; color: #383d41; }
.badge-other{ background: #fff3cd; color: #856404; }

/* ---- 卡片复制链接按钮 ---- */
.card-copy-link {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0,0,0,.55);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    font-size: 13px;
    cursor: pointer;
    opacity: 0;
    transform: scale(.9);
    transition: all .2s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.card:hover .card-copy-link {
    opacity: 1;
    transform: scale(1);
}
.card-copy-link:hover {
    background: var(--primary);
}

/* ---- 移动端复制按钮优化 ---- */
@media (max-width: 768px) {
    .card-copy-link {
        opacity: 1;
        transform: scale(1);
        width: 36px;
        height: 36px;
        font-size: 16px;
    }
}

/* ── 底部版权 ── */
.site-footer {
    text-align: center;
    padding: 20px 16px;
    margin-top: 40px;
    border-top: 1px solid #e8e8e8;
    color: #999;
    font-size: 13px;
}

/* ---- 搜索表单-inline ---- */
.search-form-inline {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    flex: 1;
}
.search-input-group {
    display: flex;
    gap: 0;
    min-width: 200px;
    max-width: 500px;
}
/* 居中上传按钮 */
.upload-btn-centered {
    display: block;
    margin: 16px auto 0;
    width: fit-content;
}
.search-input-group input {
    flex: 1;
    min-width: 0;
    border-radius: 6px 0 0 6px;
    border: 1px solid var(--border);
    border-right: none;
    padding: 0 12px;
    height: 40px;
    font-size: 14px;
    outline: none;
}
.search-input-group input:focus {
    border-color: var(--primary);
}
.search-input-group .btn {
    border-radius: 0;
    white-space: nowrap;
}
.search-input-group .btn-primary {
    border-radius: 0 6px 6px 0;
}
.search-input-group .btn-success {
    border-radius: 0 6px 6px 0;
}
.cat-select {
    height: 40px;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0 12px;
    font-size: 14px;
    background: #fff;
    min-width: 120px;
}
.cat-select:focus {
    border-color: var(--primary);
}

/* ---- 桌面/移动端显隐 ---- */
.desktop-only {
    display: block;
}
.mobile-only {
    display: none;
}

/* ---- 上传按钮（移动端） ---- */
.upload-btn-mobile {
    margin-left: auto;
}

/* ---- 移动端搜索栏 ---- */
@media (max-width: 768px) {
    .search-bar {
        padding: 16px;
    }
    .search-form-inline {
        width: 100%;
        max-width: 100%;
    }
    .search-input-group {
        max-width: 100%;
        width: 100%;
    }
    .upload-btn-centered {
        margin-top: 12px;
    }
    .desktop-only {
        display: none;
    }
    .mobile-only {
        display: block;
    }
}
