/* ================= 全局重置与基础设置 ================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    /* 禁用移动端点击高亮，让应用看起来更像 Native App */
    -webkit-tap-highlight-color: transparent; 
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #f5f7fa;
    color: #333;
    line-height: 1.5;
    /* 保证内容区域有足够的高度，并且底部留白给悬浮按钮 */
    padding-bottom: 80px; 
}

/* ================= 顶部导航栏 ================= */
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 56px;
    background-color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    z-index: 100;
}

.app-header h1 {
    font-size: 18px;
    font-weight: 600;
    color: #1a1a1a;
}

/* ================= 主体内容区 ================= */
.container {
    padding: 70px 12px 20px; /* 避开固定在顶部的 header */
}

/* 零食列表：使用 Grid 布局，移动端双列展示 */
.snack-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.loading-text {
    grid-column: span 2;
    text-align: center;
    color: #888;
    margin-top: 20px;
    font-size: 14px;
}

/* ================= 零食卡片样式 ================= */
.snack-card {
    background: #ffffff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
    display: flex;
    flex-direction: column;
    /* 点击卡片时的视觉反馈 */
    transition: transform 0.1s ease;
}

.snack-card:active {
    transform: scale(0.98);
}

.snack-image {
    width: 100%;
    aspect-ratio: 1 / 1; /* 强制正方形比例 */
    object-fit: cover; /* 保证图片不变形 */
    background-color: #eaeaea;
}

.snack-info {
    padding: 10px;
}

.snack-name {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 4px;
    /* 单行文本溢出省略号 */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.snack-price {
    color: #ff5722;
    font-size: 16px;
    font-weight: bold;
    margin-bottom: 6px;
}

.snack-detail {
    font-size: 12px;
    color: #666;
    margin-bottom: 2px;
    display: flex;
    align-items: center;
}

.snack-detail span {
    margin-right: 4px;
}

/* ================= 悬浮发布按钮 (FAB) ================= */
.fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background-color: #007aff;
    color: white;
    font-size: 32px;
    font-weight: 300;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.4);
    z-index: 99;
    cursor: pointer;
}

.fab:active {
    background-color: #0062cc;
}

/* ================= 弹窗 (Modal) ================= */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: flex;
    align-items: flex-end; /* 移动端常见的底部弹窗样式 */
    justify-content: center;
    transition: opacity 0.3s ease;
}

.modal.hidden {
    display: none;
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    background-color: #ffffff;
    width: 100%;
    max-height: 90vh; /* 防止表单太长超出屏幕 */
    border-radius: 20px 20px 0 0; /* 仅顶部圆角 */
    padding: 20px;
    overflow-y: auto; /* 内容过多时可滑动 */
    animation: slideUp 0.3s ease forwards;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-header h2 {
    font-size: 18px;
}

.close-btn {
    background: none;
    border: none;
    font-size: 28px;
    color: #999;
    padding: 0 10px;
}

/* ================= 表单与输入框 ================= */
.form-group {
    margin-bottom: 16px;
}

input[type="text"],
input[type="number"],
input[type="password"] {
    width: 100%;
    height: 44px; /* 移动端标准触控高度 */
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 0 12px;
    font-size: 15px;
    background-color: #fafafa;
    appearance: none; /* 去除 iOS 默认内阴影 */
}

input:focus {
    outline: none;
    border-color: #007aff;
    background-color: #fff;
}

/* 图片上传区域样式 */
.image-upload-group {
    margin-bottom: 20px;
}

.image-upload-label {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 160px;
    border: 2px dashed #ccc;
    border-radius: 12px;
    background-color: #f9f9f9;
    color: #888;
    overflow: hidden;
    position: relative;
}

.image-upload-label img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: absolute;
    top: 0;
    left: 0;
}

/* ================= 按钮样式 ================= */
.submit-btn,
.danger-btn,
.secondary-btn {
    width: 100%;
    height: 48px;
    border: none;
    border-radius: 24px;
    font-size: 16px;
    font-weight: 600;
    color: #fff;
    margin-top: 10px;
}

.submit-btn {
    background-color: #007aff;
}

.danger-btn {
    background-color: #ff3b30;
}

.secondary-btn {
    background-color: #8e8e93;
    margin-top: 12px;
}

/* 管理弹窗内部结构 */
.manage-body p {
    font-size: 14px;
    color: #666;
    margin-bottom: 10px;
}

.manage-actions {
    margin-top: 20px;
}
