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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

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

/* 头部样式 */
header {
    text-align: center;
    margin-bottom: 15px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
}

h1 {
    color: #4a5568;
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* 导航栏样式 */
nav {
    margin-bottom: 15px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    padding: 0 20px;
}

/* 饮食计划布局 */
.diet-plan-container {
    display: flex;
    flex-direction: row;
    gap: 20px;
    width: 100%;
    min-height: 500px;
}

.diet-plan-left {
    flex: 1;
    padding: 25px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #f7fafc;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    min-width: 0;
    float: left;
    overflow: auto;
}

.diet-plan-right {
    flex: 1;
    padding: 20px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-width: 0;
    float: left;
}

.chart-item {
    flex: 1;
    position: relative;
    min-height: 180px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px;
}

.chart-item h4 {
    margin-bottom: 10px;
    color: #4a5568;
    font-size: 1rem;
    font-weight: 600;
    text-align: center;
}

.chart-container-inner {
    width: 100%;
    height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #9ca3af;
    position: relative;
}

.chart-container-inner canvas {
    width: 100% !important;
    height: 100% !important;
}

.chart-wrapper {
    width: 100%;
    height: 300px;
    position: relative;
}

.chart-wrapper canvas {
    width: 100% !important;
    height: 100% !important;
}

@media (max-width: 768px) {
    .diet-plan-container {
        flex-direction: column;
        gap: 15px;
        min-height: auto;
    }
    
    .diet-plan-left,
    .diet-plan-right {
        flex: none;
        width: 100%;
        float: none;
        padding: 15px;
    }
    
    .diet-plan-right {
        display: flex;
        flex-direction: column;
        gap: 15px;
    }
    
    .chart-item {
        width: 100%;
        min-height: 150px;
    }
    
    .chart-container-inner {
        height: 120px;
    }
    
    .chart-container-inner canvas {
        max-height: 120px;
    }
}

nav ul {
    display: flex;
    list-style: none;
    justify-content: center;
    flex-wrap: wrap;
}

nav ul li {
    padding: 15px 20px;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.3s ease;
    position: relative;
}

nav ul li:hover {
    background-color: rgba(102, 126, 234, 0.1);
    transform: translateY(-2px);
}

nav ul li.active {
    border-bottom-color: #667eea;
    color: #667eea;
    font-weight: 600;
}

nav ul li.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 3px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 3px;
}

/* 主内容区样式 */
main {
    min-height: 500px;
    background: rgba(255, 255, 255, 0.95);
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
}

/* 标签内容样式 */
.tab-content {
    display: none;
    animation: fadeIn 0.5s ease;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 表单样式 */
.form {
    margin-bottom: 30px;
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    padding: 20px;
    background: rgba(247, 250, 252, 1);
    border-radius: 8px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
}

.form input,
.form select {
    padding: 10px 15px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 14px;
    transition: all 0.3s ease;
    background: white;
}

.form input:focus,
.form select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    transform: translateY(-1px);
}

.form button {
    padding: 10px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.form button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
}

.form button:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

/* 列表样式 */
.list {
    margin-top: 20px;
}

.list h3 {
    margin-bottom: 15px;
    color: #4a5568;
    font-size: 1.2rem;
    font-weight: 600;
}

.list ul {
    list-style: none;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.list li {
    padding: 15px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s ease;
    background: white;
}

.list li:last-child {
    border-bottom: none;
}

.list li:hover {
    background: #f7fafc;
    transform: translateX(5px);
}

.list li button {
    padding: 6px 12px;
    background: #f56565;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.list li button:hover {
    background: #e53e3e;
    transform: translateY(-1px);
}

/* 食谱列表样式 */
.recipe-list li {
    cursor: pointer;
}

.recipe-list li:hover {
    background: rgba(102, 126, 234, 0.05);
    transform: translateX(5px);
}

/* 食谱详情样式 */
.recipe-detail {
    margin-top: 20px;
    padding: 25px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #f7fafc;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    animation: slideIn 0.5s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.recipe-detail h3 {
    color: #4a5568;
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 15px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.recipe-detail p {
    margin-bottom: 10px;
    color: #4a5568;
}

.recipe-detail h4 {
    margin-top: 20px;
    margin-bottom: 10px;
    color: #4a5568;
    font-size: 1.1rem;
    font-weight: 600;
}

.recipe-detail ul,
.recipe-detail ol {
    margin-left: 20px;
    margin-bottom: 15px;
}

.recipe-detail li {
    margin-bottom: 5px;
    color: #4a5568;
    background: transparent;
    transform: none;
    padding: 0;
    border: none;
}

/* 饮食计划和分析结果样式 */
.diet-plan,
.analysis-result {
    margin-top: 20px;
    padding: 25px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #f7fafc;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.diet-plan pre,
.analysis-result pre {
    white-space: pre-wrap;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: #4a5568;
}

/* 图表容器样式 */
.chart-container {
    margin-top: 20px;
    padding: 25px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    position: relative;
    height: 400px;
}

/* 操作按钮样式 */
.actions {
    margin-top: 20px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.actions button {
    padding: 10px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.actions button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
}

/* 页脚样式 */
footer {
    margin-top: 50px;
    text-align: center;
    padding: 20px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    color: #718096;
    font-size: 14px;
}

/* 汉堡菜单按钮 */
.menu-toggle {
    display: none;
    flex-direction: column;
    justify-content: space-between;
    width: 30px;
    height: 24px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    margin-right: 15px;
    flex-shrink: 0;
}

.menu-toggle span {
    display: block;
    width: 100%;
    height: 3px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 3px;
    transition: all 0.3s ease;
}

.menu-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(6px, 6px);
}

.menu-toggle.active span:nth-child(2) {
    opacity: 0;
}

.menu-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(6px, -6px);
}

/* 移动端导航菜单 */
.mobile-nav {
    display: block;
}

.mobile-nav ul {
    display: flex;
}

@media (max-width: 768px) {
    .menu-toggle {
        display: flex;
    }
    
    header {
        display: flex;
        align-items: center;
        justify-content: flex-start;
    }
    
    .mobile-nav {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(255, 255, 255, 0.98);
        z-index: 1000;
        padding-top: 80px;
        backdrop-filter: blur(10px);
    }
    
    .mobile-nav.active {
        display: block;
        animation: fadeIn 0.3s ease;
    }
    
    .mobile-nav ul {
        flex-direction: column;
        width: 100%;
        padding: 0;
    }
    
    .mobile-nav ul li {
        width: 100%;
        text-align: center;
        padding: 20px 15px;
        font-size: 16px;
        border-bottom: 1px solid #e2e8f0;
        cursor: pointer;
        transition: all 0.3s ease;
    }
    
    .mobile-nav ul li:hover {
        background-color: rgba(102, 126, 234, 0.1);
        transform: none;
    }
    
    .mobile-nav ul li.active {
        background-color: rgba(102, 126, 234, 0.15);
        color: #667eea;
        font-weight: 600;
    }
    
    .mobile-nav ul li.active::after {
        display: none;
    }
    
    .mobile-nav ul li:first-child {
        border-top: 1px solid #e2e8f0;
    }
    
    /* 关闭按钮 */
    .mobile-nav::before {
        content: '×';
        position: absolute;
        top: 20px;
        right: 20px;
        font-size: 40px;
        color: #667eea;
        cursor: pointer;
        width: 50px;
        height: 50px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: rgba(102, 126, 234, 0.1);
        border-radius: 50%;
        transition: all 0.3s ease;
    }
    
    .mobile-nav::before:hover {
        background: rgba(102, 126, 234, 0.2);
        transform: scale(1.1);
    }
    
    /* 内容区域布局优化 */
    .tab-content {
        display: none;
        width: 100%;
    }
    
    .tab-content.active {
        display: block;
        animation: fadeIn 0.3s ease;
    }
    
    /* 左右布局改为上下布局 */
    .diet-plan,
    .nutrition-analysis,
    .health-tracking {
        display: flex;
        flex-direction: column;
        gap: 20px;
        width: 100%;
    }
    
    .diet-plan > div,
    .nutrition-analysis > div,
    .health-tracking > div {
        width: 100% !important;
        flex: none !important;
    }
    
    /* 营养分析和健康跟踪的布局 */
    main > div:not(.tab-content) {
        display: flex;
        flex-direction: column;
        gap: 20px;
    }
    
    /* 图表容器优化 */
    .chart-container {
        width: 100%;
        height: auto;
        min-height: 250px;
        margin: 15px 0;
    }
    
    /* 健康跟踪页面布局 */
    #health .tab-content.active > div:first-of-type,
    #nutrition .tab-content.active > div:nth-of-type(7) {
        display: flex;
        flex-direction: column;
        gap: 15px;
    }
    
    /* 确保所有子元素都适应移动端 */
    .tab-content.active > * {
        max-width: 100%;
        overflow-x: hidden;
    }
    
    /* 列表项优化 */
    .list li {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .list li button {
        width: 100%;
        margin-top: 5px;
    }
}

/* 健康跟踪页面布局 */
.health-chart-layout {
    display: flex;
    flex-direction: row;
    gap: 20px;
    width: 100%;
    min-height: 500px;
    margin-top: 20px;
}

.health-records-panel {
    flex: 1;
    padding: 25px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #f7fafc;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    overflow-y: auto;
}

.health-chart-panel {
    flex: 1;
    padding: 20px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.chart-wrapper {
    width: 100%;
    height: 300px;
}

@media (max-width: 768px) {
    .health-chart-layout {
        flex-direction: column;
        gap: 15px;
        min-height: auto;
    }
    
    .health-records-panel,
    .health-chart-panel {
        flex: none;
        width: 100%;
        padding: 15px;
    }
    
    .health-chart-panel {
        min-height: 300px;
    }
    
    .chart-wrapper {
        height: 250px;
    }
    
    .health-records-panel h3,
    .health-chart-panel h3 {
        font-size: 1rem;
        margin-bottom: 10px;
    }
}

/* 营养分析页面布局 */
.nutrition-chart-layout {
    display: flex;
    flex-direction: row;
    gap: 20px;
    width: 100%;
    min-height: 500px;
    margin-top: 20px;
}

.nutrition-result-panel {
    flex: 1;
    padding: 25px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #f7fafc;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    overflow-y: auto;
}

.nutrition-chart-panel {
    flex: 1;
    padding: 20px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

@media (max-width: 768px) {
    .nutrition-chart-layout {
        flex-direction: column;
        gap: 15px;
        min-height: auto;
    }
    
    .nutrition-result-panel,
    .nutrition-chart-panel {
        flex: none;
        width: 100%;
        padding: 15px;
    }
    
    .nutrition-chart-panel {
        min-height: 300px;
    }
    
    .nutrition-result-panel h3,
    .nutrition-chart-panel h3 {
        font-size: 1rem;
        margin-bottom: 10px;
    }
}

/* 响应式设计 - 平板 */
@media (max-width: 992px) {
    .app {
        padding: 15px;
    }
    
    h1 {
        font-size: 1.5rem;
    }
    
    nav ul li {
        padding: 12px 15px;
        font-size: 14px;
    }
    
    .diet-plan-container {
        flex-direction: column !important;
    }
    
    .diet-plan-left,
    .diet-plan-right {
        width: 100%;
        float: none;
    }
    
    .diet-plan-right {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 15px;
    }
    
    .chart-item {
        min-height: 200px;
    }
    
    .health-chart-layout {
        flex-direction: column;
        gap: 20px;
        min-height: auto;
    }
    
    .health-records-panel,
    .health-chart-panel {
        flex: none;
        width: 100%;
    }
    
    .nutrition-chart-layout {
        flex-direction: column;
        gap: 20px;
        min-height: auto;
    }
    
    .nutrition-result-panel,
    .nutrition-chart-panel {
        flex: none;
        width: 100%;
    }
}

/* 响应式设计 - 手机 */
@media (max-width: 768px) {
    .app {
        padding: 8px;
    }
    
    header {
        padding: 12px;
        margin-bottom: 10px;
    }
    
    h1 {
        font-size: 1.3rem;
    }
    
    nav {
        padding: 0 10px;
        margin-bottom: 10px;
    }
    
    nav ul {
        flex-direction: column;
        align-items: stretch;
    }
    
    nav ul li {
        width: 100%;
        text-align: center;
        padding: 12px 10px;
        font-size: 13px;
    }
    
    main {
        padding: 15px;
        min-height: auto;
    }
    
    h2 {
        font-size: 1.4rem;
        margin-bottom: 15px;
        padding-bottom: 8px;
    }
    
    .form {
        padding: 15px;
        margin-bottom: 20px;
        flex-direction: column;
        gap: 10px;
    }
    
    .form input,
    .form select,
    .form button {
        width: 100%;
        padding: 12px 10px;
        font-size: 14px;
    }
    
    .list {
        margin-top: 15px;
    }
    
    .list h3 {
        font-size: 1rem;
        margin-bottom: 10px;
    }
    
    .list li {
        padding: 12px 10px;
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        font-size: 13px;
    }
    
    .list li button {
        width: 100%;
        padding: 8px;
        font-size: 12px;
    }
    
    .actions {
        flex-direction: column;
    }
    
    .actions button {
        width: 100%;
    }
    
    .chart-container {
        height: 250px;
        margin-top: 15px;
        padding: 15px;
    }
    
    .diet-plan-container {
        flex-direction: column;
        gap: 15px;
        min-height: auto;
    }
    
    .diet-plan-left,
    .diet-plan-right {
        width: 100%;
        padding: 15px;
        float: none;
    }
    
    .diet-plan-right {
        display: flex;
        flex-direction: column;
        gap: 15px;
    }
    
    .chart-item {
        width: 100%;
        min-height: 180px;
    }
    
    .chart-item h4 {
        font-size: 0.9rem;
    }
    
    .chart-container canvas {
        width: 100% !important;
        height: auto !important;
    }
    
    footer {
        margin-top: 30px;
        padding: 15px;
        font-size: 12px;
    }
    
    .recipe-detail {
        padding: 15px;
        margin-top: 15px;
    }
    
    .recipe-detail h3 {
        font-size: 1.2rem;
    }
    
    .recipe-detail p,
    .recipe-detail li {
        font-size: 13px;
    }
}

/* 响应式设计 - 小屏手机 */
@media (max-width: 480px) {
    .app {
        padding: 5px;
    }
    
    header {
        padding: 10px;
    }
    
    h1 {
        font-size: 1.1rem;
    }
    
    nav ul li {
        padding: 10px 8px;
        font-size: 12px;
    }
    
    main {
        padding: 12px;
    }
    
    h2 {
        font-size: 1.2rem;
        margin-bottom: 12px;
    }
    
    .form {
        padding: 12px;
        margin-bottom: 15px;
        gap: 8px;
    }
    
    .form input,
    .form select,
    .form button {
        padding: 10px 8px;
        font-size: 13px;
    }
    
    .list li {
        padding: 10px 8px;
        font-size: 12px;
    }
    
    .chart-container {
        height: 200px;
        padding: 10px;
    }
    
    .diet-plan-left,
    .diet-plan-right {
        padding: 12px;
    }
    
    .chart-item {
        min-height: 150px;
    }
    
    footer {
        margin-top: 20px;
        padding: 12px;
        font-size: 11px;
    }
}

/* 触摸设备优化 */
@media (hover: none) and (pointer: coarse) {
    nav ul li:hover,
    .form button:hover,
    .list li button:hover,
    .actions button:hover {
        transform: none;
    }
    
    nav ul li:active,
    .form button:active,
    .list li button:active,
    .actions button:active {
        transform: scale(0.98);
        opacity: 0.9;
    }
    
    .list li:hover,
    .recipe-list li:hover {
        transform: none;
        background: white;
    }
    
    .form input:focus,
    .form select:focus {
        transform: none;
    }
}

/* 滚动条样式 */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #5a6fd8 0%, #6a4298 100%);
}

/* 标题样式 */
h2 {
    color: #4a5568;
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #e2e8f0;
}

/* 加载动画 */
@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.05);
        opacity: 0.8;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.loading {
    animation: pulse 1.5s infinite;
}

/* 卡片悬停效果 */
.card {
    transition: all 0.3s ease;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}