/* 全局样式 */
:root {
    --primary-color: #8B4513; /* 棕色 */
    --secondary-color: #2F4F2F; /* 墨绿 */
    --accent-color: #D2B48C; /* 米色 */
    --background-color: #FFF8DC; /* 浅米色 */
    --text-color: #333333;
    --light-text: #666666;
    --border-color: #E0E0E0;
    --shadow-color: rgba(0, 0, 0, 0.1);
    --success-color: #4CAF50;
    --error-color: #F44336;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
    overflow-x: hidden;
}

.app-container {
    max-width: 450px;
    margin: 0 auto;
    background-color: white;
    min-height: 100vh;
    box-shadow: 0 0 20px var(--shadow-color);
}

/* 导航栏 */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background-color: var(--primary-color);
    color: white;
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar-title {
    font-size: 1.2rem;
    font-weight: bold;
}

.navbar-menu {
    display: flex;
    gap: 0.5rem;
}

.nav-btn {
    background-color: transparent;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.3s ease;
}

.nav-btn:hover,
.nav-btn.active {
    background-color: rgba(255, 255, 255, 0.2);
}

/* 页面通用样式 */
.page {
    display: none;
    padding: 1.5rem;
}

.page.active {
    display: block;
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.section-title {
    font-size: 1.2rem;
    font-weight: bold;
    margin-bottom: 1rem;
    color: var(--secondary-color);
    border-bottom: 2px solid var(--accent-color);
    padding-bottom: 0.5rem;
}

/* 首页样式 */
.hero-section {
    text-align: center;
    margin-bottom: 2rem;
    padding: 2rem 0;
    background-color: rgba(139, 69, 19, 0.05);
    border-radius: 8px;
}

.hero-title {
    font-size: 2rem;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
    font-family: 'KaiTi', 'STKaiti', serif;
}

.hero-subtitle {
    color: var(--light-text);
    font-size: 1rem;
}

.input-section {
    margin-bottom: 2rem;
}

#poetry-input {
    width: 100%;
    height: 120px;
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    resize: vertical;
    font-size: 1rem;
    font-family: 'PingFang SC', 'Microsoft YaHei', sans-serif;
    line-height: 1.6;
}

.input-counter {
    text-align: right;
    font-size: 0.8rem;
    color: var(--light-text);
    margin-top: 0.5rem;
}

.primary-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    margin-top: 1rem;
    width: 100%;
    transition: background-color 0.3s ease;
}

.primary-btn:hover:not(:disabled) {
    background-color: #A0522D;
}

.primary-btn:disabled {
    background-color: #CCCCCC;
    cursor: not-allowed;
}

.recommendation-list {
    display: grid;
    gap: 1rem;
}

.recommendation-item {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    cursor: pointer;
    transition: box-shadow 0.3s ease;
}

.recommendation-item:hover {
    box-shadow: 0 4px 12px var(--shadow-color);
}

.recommendation-item h3 {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
    font-family: 'KaiTi', 'STKaiti', serif;
}

.recommendation-item p {
    font-size: 0.9rem;
    color: var(--light-text);
    margin-bottom: 0.5rem;
}

/* 结果页样式 */
.result-header {
    text-align: center;
    margin-bottom: 2rem;
}

.dish-title {
    font-size: 1.8rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
    font-family: 'KaiTi', 'STKaiti', serif;
}

.dish-interpretation {
    color: var(--light-text);
    font-style: italic;
    line-height: 1.8;
}

.dish-image-section {
    margin-bottom: 2rem;
    text-align: center;
}

.dish-image {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 4px 12px var(--shadow-color);
}

.image-placeholder {
    padding: 4rem 2rem;
    background-color: #F5F5F5;
    border-radius: 8px;
    color: var(--light-text);
}

.cooking-guide-section {
    margin-bottom: 2rem;
}

.guide-section {
    margin-bottom: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.guide-toggle-btn {
    width: 100%;
    padding: 1rem;
    text-align: left;
    background-color: #F9F9F9;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    font-weight: bold;
    color: var(--secondary-color);
    border-radius: 8px 8px 0 0;
    transition: background-color 0.3s ease;
}

.guide-toggle-btn:hover {
    background-color: #F0F0F0;
}

.guide-toggle-btn::after {
    content: '▼';
    float: right;
    font-size: 0.8rem;
    transition: transform 0.3s ease;
}

.guide-toggle-btn.active::after {
    transform: rotate(180deg);
}

.guide-content {
    padding: 1rem;
    display: none;
}

.guide-content.active {
    display: block;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from { opacity: 0; max-height: 0; }
    to { opacity: 1; max-height: 500px; }
}

#ingredients-list,
#steps-list {
    padding-left: 1.5rem;
}

#ingredients-list li,
#steps-list li {
    margin-bottom: 0.5rem;
    line-height: 1.6;
}

.result-actions {
    display: flex;
    gap: 1rem;
}

.secondary-btn {
    flex: 1;
    background-color: white;
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
    padding: 1rem;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.secondary-btn:hover {
    background-color: rgba(139, 69, 19, 0.05);
}

/* 分享页样式 */
.share-upload-section {
    margin-bottom: 2rem;
}

.image-upload-area {
    margin-bottom: 1rem;
}

.upload-label {
    display: block;
    cursor: pointer;
}

.preview-container {
    width: 100%;
    height: 200px;
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.upload-placeholder {
    text-align: center;
    color: var(--light-text);
}

.upload-hint {
    font-size: 0.8rem;
    margin-top: 0.5rem;
}

.preview-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: absolute;
    top: 0;
    left: 0;
}

#work-description {
    width: 100%;
    height: 80px;
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    resize: vertical;
    font-size: 1rem;
    margin-bottom: 0.5rem;
}

.works-list {
    display: grid;
    gap: 1rem;
}

.work-item {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: box-shadow 0.3s ease;
}

.work-item:hover {
    box-shadow: 0 4px 12px var(--shadow-color);
}

.work-item-image {
    width: 100%;
    height: 150px;
    object-fit: cover;
}

.work-item-info {
    padding: 1rem;
}

.work-item-author {
    font-size: 0.9rem;
    color: var(--light-text);
    margin-bottom: 0.5rem;
}

.work-item-description {
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.work-item-actions {
    display: flex;
    gap: 1rem;
    font-size: 0.8rem;
    color: var(--light-text);
}

/* 作品详情页样式 */
.work-detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.author-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--accent-color);
    margin-right: 1rem;
}

.author-info {
    display: flex;
    align-items: center;
}

.author-name {
    font-weight: bold;
    margin-right: 1rem;
}

.work-time {
    font-size: 0.8rem;
    color: var(--light-text);
}

.back-btn {
    background-color: transparent;
    border: 1px solid var(--border-color);
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.3s ease;
}

.back-btn:hover {
    background-color: #F5F5F5;
}

.work-detail-image {
    width: 100%;
    height: auto;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.work-description {
    margin-bottom: 1rem;
    line-height: 1.8;
}

.work-actions {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
}

.like-btn,
.share-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background-color: transparent;
    border: 1px solid var(--border-color);
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.like-btn:hover,
.share-btn:hover {
    background-color: #F5F5F5;
}

.like-btn.liked {
    background-color: var(--error-color);
    color: white;
    border-color: var(--error-color);
}

.comments-section {
    margin-top: 2rem;
}

.comment-input-area {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

#comment-input {
    flex: 1;
    height: 40px;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    resize: none;
    font-size: 0.9rem;
}

.submit-comment-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 0 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.3s ease;
}

.submit-comment-btn:hover:not(:disabled) {
    background-color: #A0522D;
}

.submit-comment-btn:disabled {
    background-color: #CCCCCC;
    cursor: not-allowed;
}

.comments-list {
    display: grid;
    gap: 1rem;
}

.comment-item {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
}

.comment-author {
    font-weight: bold;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.comment-content {
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.comment-time {
    font-size: 0.8rem;
    color: var(--light-text);
    text-align: right;
}

/* 个人中心页样式 */
.profile-header {
    display: flex;
    align-items: center;
    margin-bottom: 2rem;
    padding: 2rem 1rem;
    background-color: rgba(139, 69, 19, 0.05);
    border-radius: 8px;
}

.profile-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background-color: var(--accent-color);
    margin-right: 1.5rem;
}

.profile-name {
    font-size: 1.2rem;
    font-weight: bold;
    margin-bottom: 0.5rem;
    color: var(--primary-color);
}

.profile-desc {
    color: var(--light-text);
    font-size: 0.9rem;
}

.profile-stats {
    display: flex;
    justify-content: space-around;
    margin-bottom: 2rem;
}

.stat-item {
    text-align: center;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.stat-label {
    color: var(--light-text);
    font-size: 0.9rem;
}

.profile-sections {
    display: grid;
    gap: 2rem;
}

.my-works-list,
.my-activities-list {
    display: grid;
    gap: 1rem;
}

/* 加载遮罩 */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.loading-overlay.active {
    display: flex;
}

.loading-content {
    background-color: white;
    padding: 2rem;
    border-radius: 8px;
    text-align: center;
    box-shadow: 0 4px 12px var(--shadow-color);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #F5F5F5;
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 分享弹窗 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal.active {
    display: flex;
}

.modal-content {
    background-color: white;
    padding: 2rem;
    border-radius: 8px;
    width: 90%;
    max-width: 300px;
    box-shadow: 0 4px 12px var(--shadow-color);
}

.modal-title {
    font-size: 1.2rem;
    font-weight: bold;
    margin-bottom: 1rem;
    text-align: center;
}

.share-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 1rem;
}

.share-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.share-option:hover {
    background-color: #F5F5F5;
}

.share-icon {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.close-modal-btn {
    width: 100%;
    padding: 0.8rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    background-color: white;
    transition: background-color 0.3s ease;
}

.close-modal-btn:hover {
    background-color: #F5F5F5;
}

/* 响应式设计 */
@media (max-width: 320px) {
    .app-container {
        padding: 0;
    }
    
    .page {
        padding: 1rem;
    }
    
    .hero-title {
        font-size: 1.5rem;
    }
    
    .share-options {
        grid-template-columns: 1fr;
    }
}