/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f4f4f4;
}

header {
    background-color: #4CAF50;
    color: white;
    padding: 30px 20px;
    text-align: center;
    transition: all 0.3s ease;
}

header h1 {
    margin-bottom: 10px;
    font-size: 28px;
}

header p {
    font-size: 16px;
}

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

footer {
    background-color: #333;
    color: white;
    text-align: center;
    padding: 10px;
    margin-top: 40px;
}

/* 按钮样式 */
.btn {
    display: inline-block;
    padding: 8px 16px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    text-decoration: none;
    font-size: 14px;
    transition: background-color 0.3s;
    margin-top: 8px;
}

.btn:hover {
    background-color: #45a049;
}

/* 物品网格 */
.items {
    margin-top: 30px;
}

.items h2 {
    text-align: center;
    margin-bottom: 20px;
    color: #333;
}

.items-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
}

/* 物品卡片 */
.item-card {
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    padding: 12px;
    text-align: center;
    transition: transform 0.3s;
    display: flex;
    flex-direction: column;
    height: 100%;
    max-height: 380px;
}

.item-image-container {
    position: relative;
    margin-bottom: 10px;
    flex-shrink: 0;
}

.item-image-container img {
    width: 100%;
    height: 160px;
    object-fit: cover;
    border-radius: 4px;
}

.item-status {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 10;
}

.status-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 15px;
    font-size: 12px;
    font-weight: bold;
}

.donation-message-small {
    font-size: 11px;
    color: #666;
    margin: 4px 0 0 0;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    max-height: 40px;
}

.item-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.no-image {
    width: 100%;
    height: 160px;
    background-color: #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    color: #999;
}

.item-card h3 {
    margin-bottom: 6px;
    color: #333;
    font-size: 16px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.price {
    font-weight: bold;
    color: #4CAF50;
    margin-bottom: 8px;
    font-size: 14px;
}

/* 主页捐助人信息 */
.donor-info-card {
    margin: 6px 0 10px 0;
    padding: 8px;
    background-color: #f0f8f0;
    border-radius: 4px;
    font-size: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-shrink: 0;
}

/* 统一查看详情按钮样式 */
.item-card .btn {
    margin-top: auto;
    padding: 8px 16px;
    font-size: 14px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 4px;
    text-decoration: none;
    display: inline-block;
    transition: background-color 0.3s;
    width: 100%;
    box-sizing: border-box;
}

.item-card .btn:hover {
    background-color: #45a049;
}

.donor-avatar-card {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    object-fit: contain;
    background-color: #f0f0f0;
    margin-bottom: 4px;
}

.donor-name-card {
    margin: 0 0 2px 0;
    font-weight: bold;
    color: #333;
    font-size: 12px;
}

/* 捐赠状态 */
.donated-status {
    margin: 10px 0;
}

.status-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 15px;
    font-size: 12px;
    font-weight: bold;
    margin-bottom: 8px;
}

.status-badge.donated {
    background-color: #4CAF50;
    color: white;
}

.status-badge.not-donated {
    background-color: #ff9800;
    color: white;
}

/* 捐助人信息 */
.donor-info {
    margin-top: 10px;
    padding: 10px;
    background-color: #f9f9f9;
    border-radius: 8px;
}

.donor-details {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
}

.donor-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: contain;
    background-color: #f0f0f0;
}

.no-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background-color: #e0e0e0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
}

.donor-name {
    font-size: 18px;
    font-weight: bold;
    color: #333;
}

/* 禁用按钮 */
.btn.disabled {
    background-color: #9e9e9e;
    cursor: not-allowed;
}

/* 物品详情页 */
.item-detail {
    margin-top: 30px;
}

.back-link {
    margin-bottom: 15px;
}

.back-link a {
    color: #4CAF50;
    text-decoration: none;
    font-weight: bold;
}

.item-content {
    display: flex;
    flex-wrap: wrap;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    padding: 20px;
}

.item-image {
    flex: 1;
    min-width: 300px;
    margin-right: 20px;
}

.item-image img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
}

.item-info {
    flex: 1;
    min-width: 300px;
}

.item-info h2 {
    margin-bottom: 15px;
    color: #333;
}

.description {
    margin: 15px 0;
}

.description h3 {
    margin-bottom: 8px;
    color: #555;
}

.action-buttons {
    margin-top: 20px;
    display: flex;
    gap: 10px;
}

.donate-btn {
    background-color: #4CAF50;
}

.contact-btn {
    background-color: #2196F3;
}

/* 弹窗样式 */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.4);
}

.modal-content {
    background-color: white;
    margin: 15% auto;
    padding: 20px;
    border: 1px solid #888;
    width: 80%;
    max-width: 500px;
    border-radius: 8px;
    position: relative;
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover {
    color: black;
}

.qrcode-image,
.contact-image {
    max-width: 100%;
    height: auto;
    margin: 20px 0;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

/* 登录表单 */
.login-form {
    max-width: 400px;
    margin: 50px auto;
    background-color: white;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.login-form h2 {
    text-align: center;
    margin-bottom: 20px;
    color: #333;
}

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

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: #555;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

/* 后台管理 */
.admin-nav {
    margin-top: 10px;
}

.admin-nav a {
    color: white;
    text-decoration: none;
    padding: 5px 10px;
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.admin-section {
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    padding: 20px;
    margin-bottom: 30px;
}

.admin-section h2 {
    margin-bottom: 20px;
    color: #333;
    border-bottom: 2px solid #4CAF50;
    padding-bottom: 10px;
}

.items-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.item-admin-card {
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 20px;
    background-color: #f9f9f9;
    margin-bottom: 20px;
}

.item-admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.item-admin-header h3 {
    margin: 0;
    flex: 1;
}

.item-admin-info {
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
}

.donor-preview {
    margin-top: 10px;
    padding: 10px;
    background-color: #e8f5e8;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.item-admin-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 15px;
}

.donate-form {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #ddd;
}

.edit-btn {
    background-color: #2196F3;
}

.delete-btn {
    background-color: #f44336;
}

.cancel-btn {
    background-color: #9e9e9e;
}

.not-donate-btn {
    background-color: #ff9800;
}

.edit-form {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #ddd;
}

.current-image {
    margin-top: 10px;
    font-size: 14px;
    color: #666;
}

.no-image-text {
    margin-top: 10px;
    font-size: 14px;
    color: #999;
}

/* 图片预览区域 */
.image-preview {
    margin-top: 10px;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: #f9f9f9;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-preview img {
    max-width: 100%;
    max-height: 400px;
}



/* 响应式设计 - 所有设备都显示两列 */
@media (max-width: 1024px) {
    .items-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    
    .item-card {
        padding: 12px;
        max-height: 360px;
    }
    
    .item-image-container img {
        height: 160px;
    }
    
    .no-image {
        height: 160px;
    }
}

@media (max-width: 768px) {
    .items-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
        padding: 0 8px;
    }
    
    .item-card {
        padding: 10px;
        max-height: 340px;
    }
    
    .item-image-container img {
        height: 140px;
    }
    
    .no-image {
        height: 140px;
    }
    
    .item-card h3 {
        font-size: 16px;
    }
    
    .price {
        font-size: 14px;
    }
    
    .item-card .btn {
        font-size: 14px;
        padding: 8px 16px;
    }
    
    header {
        padding: 20px 15px;
    }
    
    header h1 {
        font-size: 24px;
    }
    
    main {
        padding: 15px;
    }
}

@media (max-width: 480px) {
    .items-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        padding: 0 6px;
    }
    
    .item-card {
        padding: 8px;
        max-height: 320px;
    }
    
    .item-image-container img {
        height: 120px;
    }
    
    .no-image {
        height: 120px;
        font-size: 12px;
    }
    
    .item-card h3 {
        font-size: 14px;
        margin-bottom: 6px;
    }
    
    .price {
        font-size: 12px;
        margin-bottom: 8px;
    }
    
    .item-card .btn {
        font-size: 12px;
        padding: 6px 12px;
    }
    
    .donor-info-card {
        padding: 6px;
        font-size: 12px;
    }
    
    .donor-avatar-card {
        width: 30px;
        height: 30px;
    }
    
    header {
        padding: 15px 10px;
    }
    
    header h1 {
        font-size: 20px;
    }
    
    header p {
        font-size: 14px;
    }
    
    main {
        padding: 10px;
    }
    
    .action-buttons {
        flex-direction: column;
    }
    
    .action-buttons .btn {
        width: 100%;
        text-align: center;
    }
}

@media (max-width: 360px) {
    .items-grid {
        gap: 6px;
    }
    
    .item-card {
        padding: 6px;
        max-height: 300px;
    }
    
    .item-image-container img {
        height: 100px;
    }
    
    .no-image {
        height: 100px;
    }
    
    .item-card h3 {
        font-size: 12px;
    }
    
    .price {
        font-size: 11px;
    }
    
    .item-card .btn {
        font-size: 11px;
        padding: 5px 10px;
    }
}