/* 统一的CSS样式文件 - 移动端图片展示网站 */

/* 基础重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
    max-width: 100%;
    overflow-x: hidden;
}

/* 头部样式 */
.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1rem;
    text-align: center;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.header h1 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.header p {
    font-size: 0.9rem;
    opacity: 0.9;
}

/* 主要内容区域 */
.main-content {
    margin-top: 160px;
    margin-bottom: 80px;
    padding: 1rem;
    min-height: calc(100vh - 240px);
}

/* 图片网格布局 - 首页使用 */
.image-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin: 1rem;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
}

.image-item {
    background: white;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: transform 0.3s ease;
    cursor: pointer;
    width: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

.image-item:hover {
    transform: translateY(-2px);
}

/* 关键修改：让图片填满整个网格区域 */
.image-item img {
    width: 100%;
    height: auto;
    aspect-ratio: 1 / 1; /* 设置1:1的宽高比，确保图片是正方形 */
    object-fit: cover; /* 改为cover，让图片填满整个区域，超出部分裁剪 */
    border-radius: 5px 5px 0 0;
    pointer-events: none; /* 防止图片阻止点击事件 */
    display: block;
}

.image-info {
    padding: 0.5rem;
    flex-shrink: 0;
}

.image-title {
    font-size: 0.9rem;
    font-weight: bold;
    margin-bottom: 0.3rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.image-date {
    font-size: 0.8rem;
    color: #666;
}

/* 管理员页面图片网格布局 */
.admin-image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 6px;
    margin-bottom: 2rem;
}

.admin-image-item {
    background: white;
    border-radius: 3px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    transition: transform 0.2s ease;
    cursor: pointer;
    position: relative;
    padding: 3px;
}

.admin-image-item:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0,0,0,0.12);
}

.admin-image-item img {
    width: 100%;
    height: 70px;
    object-fit: cover;
    border-radius: 2px;
    pointer-events: none; /* 防止图片阻止点击事件 */
}

.admin-image-info {
    padding: 3px 0;
    font-size: 0.65rem;
    line-height: 1.1;
}

.admin-image-title {
    font-weight: bold;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 1px;
    font-size: 0.7rem;
}

.admin-image-date {
    color: #666;
    font-size: 0.6rem;
}

/* 模态框样式 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.9);
    z-index: 2000;
    overflow: auto;
}

.modal-content {
    position: relative;
    margin: 5% auto;
    width: 90%;
    max-width: 600px;
    background: white;
    border-radius: 10px;
    padding: 1rem;
    word-wrap: break-word;
    overflow-wrap: break-word;
    box-sizing: border-box;
}

.modal-image {
    width: 100%;
    max-height: 70vh;
    object-fit: contain;
    cursor: pointer;
    pointer-events: auto;
}

#modalInfo {
    padding: 1rem;
    text-align: center;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

#modalInfo h3 {
    margin: 0 0 0.5rem 0;
    color: #333;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
}

.image-description {
    margin: 0.5rem 0;
    padding: 0.8rem;
    background: #f8f9fa;
    border-radius: 5px;
    border-left: 3px solid #667eea;
    text-align: left;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.image-description p {
    margin: 0;
    line-height: 1.4;
    font-size: 0.9rem;
    word-wrap: break-word;
    word-break: break-word;
    white-space: pre-wrap;
    overflow-wrap: break-word;
}

.image-description strong {
    color: #667eea;
}

.close-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: #ff4757;
    color: white;
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 评论区域 */
.comments-section {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #eee;
}

.comment {
    background: #f8f9fa;
    padding: 0.8rem;
    margin-bottom: 0.5rem;
    border-radius: 5px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.comment-author {
    font-weight: bold;
    color: #667eea;
    margin-bottom: 0.3rem;
}

.comment-content {
    font-size: 0.9rem;
    word-wrap: break-word;
    word-break: break-word;
    white-space: pre-wrap;
    overflow-wrap: break-word;
}

.comment-form {
    margin-top: 1rem;
}

.comment-form textarea {
    width: 100%;
    padding: 0.8rem;
    border: 1px solid #ddd;
    border-radius: 5px;
    resize: vertical;
    min-height: 80px;
    font-size: 0.9rem;
}

/* 表单样式 */
.form-container {
    background: white;
    padding: 1.5rem;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    margin-bottom: 2rem;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: bold;
    color: #333;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.8rem;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 0.9rem;
}

.btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 0.8rem 1.5rem;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: opacity 0.3s ease;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.btn:hover {
    opacity: 0.9;
}

.btn-secondary {
    background: #6c757d;
}

.btn-danger {
    background: #ff4757;
}

/* 底部导航 */
.footer-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #28a745;
    display: flex;
    justify-content: space-around;
    padding: 0.8rem 0;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    z-index: 1000;
}

.nav-btn {
    background: none;
    border: none;
    color: white;
    font-size: 0.8rem;
    cursor: pointer;
    text-align: center;
    padding: 0.5rem;
    border-radius: 5px;
    transition: background 0.3s ease;
}

.nav-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.nav-btn i {
    display: block;
    font-size: 1.2rem;
    margin-bottom: 0.3rem;
}

/* 响应式设计 */
@media (max-width: 1200px) {
    .image-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
        margin: 1rem;
        max-width: 1000px;
    }
}

@media (max-width: 768px) {
    .image-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        margin: 0.5rem;
        max-width: 100%;
    }
    
    .header h1 {
        font-size: 1.3rem;
    }
    
    .main-content {
        margin-top: 140px;
        padding: 0.5rem;
    }
    
    .image-info {
        padding: 0.4rem;
    }
    
    .image-title {
        font-size: 0.85rem;
        line-height: 1.2;
    }
    
    .image-date {
        font-size: 0.75rem;
    }
    
    /* 修改手机端的图片显示 */
    .image-item img {
        aspect-ratio: 1 / 1;
        object-fit: cover;
    }
}

@media (max-width: 480px) {
    .image-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
        margin: 0.3rem;
        max-width: 100%;
    }
    
    .header h1 {
        font-size: 1.2rem;
    }
    
    .main-content {
        margin-top: 140px;
        padding: 0.5rem;
    }
    
    .footer-nav {
        padding: 0.6rem 0;
    }
    
    .image-info {
        padding: 0.3rem;
    }
    
    .image-title {
        font-size: 0.8rem;
        line-height: 1.1;
    }
    
    .image-date {
        font-size: 0.7rem;
    }
    
    /* 修改小屏手机的图片显示 */
    .image-item img {
        aspect-ratio: 1 / 1;
        object-fit: cover;
    }
}

/* 工具类 */
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.hidden { display: none; }
.alert {
    padding: 0.8rem;
    border-radius: 5px;
    margin-bottom: 1rem;
}
.alert-success { background: #d4edda; color: #155724; }
.alert-error { background: #f8d7da; color: #721c24; }