/* ========== 全局变量 & 基础重置 ========== */
:root {
    --bg: #f5f5f5;
    --card-bg: #ffffff;
    --text: #333;
    --primary: #6c8e8e;
    --radius: 16px;
    --shadow: 0 2px 8px rgba(0,0,0,0.04);
}

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

html, body {
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

main {
    flex: 1 0 auto;
}

a {
    color: var(--primary);
    text-decoration: none;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* ========== 前台头部 ========== */
.site-header {
    background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: nowrap;
}

.logo {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--text);
    white-space: nowrap;
    margin-right: 15px;
}

/* ========== 搜索栏 ========== */
.search-bar {
    display: flex;
    gap: 8px;
    flex-wrap: nowrap;
    align-items: center;
}

.search-bar input {
    padding: 10px 16px;
    border: 1px solid #ddd;
    border-radius: 50px;
    outline: none;
    min-width: 0;
    width: 180px;
    max-width: 100%;
}

.search-bar button {
    padding: 10px 18px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
}

/* ========== 公告滚动 ========== */
.announcement-bar {
    background: #eef5f5;
    padding: 8px 0;
    overflow: hidden;
    position: relative;
    height: 32px;
}

.announcement-item {
    display: none;
    white-space: nowrap;
    animation: scroll-text 15s linear infinite;
}

.announcement-item.active {
    display: block;
}

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

/* ========== 专辑 & 套图卡片网格 ========== */
.album-grid,
.gallery-grid {
    display: grid;
    gap: 20px;
}

.album-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}

.gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}

.album-card,
.gallery-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    display: block;
}

/* 封面容器 - 图片宽度撑满 */
.album-card .card-img-container,
.gallery-card .card-img-container {
    width: 100%;
    background: #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.album-card .card-img-container img,
.gallery-card .card-img-container img {
    width: 100%;
    height: auto;
    display: block;
}

.no-image {
    width: 100%;
    padding: 40px 0;
    text-align: center;
    color: #aaa;
    font-size: 0.9rem;
}

.card-body {
    padding: 15px;
}

.card-body h3 {
    font-size: 1.1rem;
    margin-bottom: 4px;
}

.card-body small {
    color: #666;
}

/* ========== Masonry 瀑布流 (PC) ========== */
.gallery-masonry {
    margin: 0 auto;
    position: relative;
    width: 100%;
}

.masonry-item {
    width: calc(33.333% - 10px);
    margin-bottom: 15px;
    border-radius: var(--radius);
    overflow: hidden;
    background: #fff;
    box-shadow: var(--shadow);
}

.masonry-item a {
    display: block;
}

.masonry-item img {
    width: 100%;
    height: auto;
    min-height: 150px;           /* 防止未加载时高度塌陷堆叠 */
    background: #f0f0f0;
}

@media (max-width: 992px) and (min-width: 769px) {
    .masonry-item {
        width: calc(50% - 10px);
    }
}

@media (max-width: 768px) {
    .gallery-masonry {
        display: none;
    }
}

/* ========== 灯箱 ========== */
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0,0,0,0.92);
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s;
}

.lightbox.active {
    opacity: 1;
    visibility: visible;
}

.lightbox-backdrop {
    position: absolute;
    inset: 0;
}

.lightbox-content {
    position: relative;
    max-width: 90vw;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow: hidden;
}

.lightbox-slide {
    display: flex;
    transition: transform 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    will-change: transform;
}

.lightbox-slide img {
    max-width: 90vw;
    max-height: 80vh;
    object-fit: contain;
    border-radius: 8px;
    flex-shrink: 0;
    width: 100%;
    transition: transform 0.25s ease;
}

.lightbox-caption {
    color: #fff;
    margin-top: 8px;
    font-size: 0.9rem;
}

.lightbox-close {
    position: absolute;
    top: 15px;
    right: 25px;
    background: none;
    border: none;
    color: rgba(255,255,255,0.8);
    font-size: 2rem;
    cursor: pointer;
    z-index: 3;
}

.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255,255,255,0.15);
    border: none;
    color: #fff;
    font-size: 2.5rem;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 2;
    backdrop-filter: blur(4px);
}

.lightbox-prev {
    left: 20px;
}

.lightbox-next {
    right: 20px;
}

.lightbox-counter {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255,255,255,0.9);
    font-size: 0.9rem;
}

@media (max-width: 768px) {
    .lightbox-content img {
        max-height: 70vh;
    }
    .lightbox-nav {
        width: 40px;
        height: 40px;
        font-size: 2rem;
    }
}

/* ========== 搜索列表 ========== */
.search-list {
    list-style: none;
    padding: 0;
}

.search-list li {
    margin-bottom: 10px;
}

.badge {
    display: inline-block;
    background: var(--primary);
    color: #fff;
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 20px;
    margin-right: 8px;
}

/* ========== 广告位 ========== */
.ad-slot-lightbox {
    position: absolute;
    bottom: 70px;
    left: 50%;
    transform: translateX(-50%);
}

/* ========== 前台页脚 ========== */
.site-footer {
    background: #fff;
    text-align: center;
    padding: 20px;
    border-top: 1px solid #eee;
    flex-shrink: 0;
}

.site-footer a {
    color: var(--primary);
}

/* ========== 后台全局样式 ========== */
.admin-body {
    display: flex;
    min-height: 100vh;
    background: #f4f6f9;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.admin-sidebar {
    width: 230px;
    background: #2d3a3a;
    color: #cfd8d8;
    display: flex;
    flex-direction: column;
    padding: 30px 0 20px;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    overflow-y: auto;
    z-index: 100;
}

.sidebar-brand {
    padding: 0 20px 25px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    margin-bottom: 15px;
}

.sidebar-brand a {
    color: #fff;
    font-size: 1.3rem;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.sidebar-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 0 10px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 15px;
    border-radius: 10px;
    color: #b0bec5;
    transition: all 0.2s;
    font-size: 0.95rem;
}

.sidebar-nav a:hover {
    background: rgba(255,255,255,0.08);
    color: #fff;
}

.sidebar-nav a.active {
    background: rgba(255,255,255,0.15);
    color: #fff;
    font-weight: 500;
}

.nav-icon {
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
}

.nav-logout {
    margin-top: auto;
    opacity: 0.8;
}

.admin-main {
    flex: 1;
    margin-left: 230px;
    padding: 35px 40px;
    max-width: 1200px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 35px;
}

.stat-card {
    background: #fff;
    border-radius: 16px;
    padding: 25px 20px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.04);
}

.stat-card .label {
    font-size: 0.85rem;
    color: #777;
    margin-bottom: 8px;
}

.stat-card .value {
    font-size: 2rem;
    font-weight: 600;
    color: #2d3a3a;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0,0,0,0.04);
}

.admin-table th,
.admin-table td {
    padding: 14px 18px;
    text-align: left;
    border-bottom: 1px solid #f0f0f0;
}

.admin-table th {
    background: #fafbfc;
    font-weight: 500;
    color: #555;
    font-size: 0.9rem;
}

.admin-table tr:last-child td {
    border-bottom: none;
}

.admin-table tr:hover td {
    background: #f9fbfb;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 9px 20px;
    border-radius: 30px;
    background: #5a7a7a;
    color: #fff;
    font-size: 0.9rem;
    border: none;
    cursor: pointer;
    transition: background 0.2s;
}

.btn:hover {
    background: #4a6868;
}

.btn-delete {
    background: #c0392b;
}

.btn-delete:hover {
    background: #a93226;
}

.btn-sm {
    padding: 6px 16px;
    font-size: 0.85rem;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: #444;
    font-size: 0.9rem;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 11px 15px;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    font-size: 0.95rem;
    background: #fff;
    transition: border 0.2s;
    outline: none;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    border-color: #5a7a7a;
    box-shadow: 0 0 0 3px rgba(90,122,122,0.1);
}

textarea {
    resize: vertical;
}

.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    flex-wrap: wrap;
    gap: 15px;
}

/* 移动端两列 */
@media (max-width: 480px) {
    .album-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    .card-body h3 {
        font-size: 0.9rem;
    }
}

/* 响应式：后台侧边栏 */
@media (max-width: 768px) {
    .admin-sidebar {
        width: 100%;
        height: auto;
        position: relative;
        padding: 15px;
    }
    .admin-main {
        margin-left: 0;
        padding: 20px;
    }
    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }
}