/* css/modern.css - 高性能、移动端优先、现代UI */

:root {
    --primary-color: #ff6b00; /* 美团/饿了么风格橙 */
    --primary-gradient: linear-gradient(135deg, #ff9000 0%, #ff5000 100%);
    --bg-color: #f5f6f8;
    --card-bg: #ffffff;
    --text-main: #333333;
    --text-sub: #999999;
    --border-radius-lg: 16px;
    --border-radius-md: 12px;
    --border-radius-sm: 8px;
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
    --shadow-float: 0 8px 24px rgba(255, 107, 0, 0.25);
    --safe-area-bottom: env(safe-area-inset-bottom, 20px);
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    overflow-x: hidden;
    /* 禁止整体滚动，由内部容器滚动 */
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* --- 顶部导航栏 (沉浸式) --- */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 12px 16px;
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
}

.search-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.search-bar {
    flex: 1;
    background: #f0f0f0;
    border-radius: 20px;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    font-size: 14px;
    color: var(--text-sub);
    transition: all 0.2s;
}

.search-bar:focus-within {
    background: #fff;
    box-shadow: 0 0 0 2px var(--primary-color);
}

.search-icon {
    margin-right: 8px;
    opacity: 0.5;
}

.user-avatar-mini {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 14px;
    cursor: pointer;
    flex-shrink: 0;
}

/* --- 主体布局 (左右分栏) --- */
.main-container {
    flex: 1;
    display: flex;
    overflow: hidden; /* 防止双重滚动 */
    position: relative;
}

/* 左侧分类菜单 */
.category-sidebar {
    width: 88px;
    background: #fff;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Firefox */
}
.category-sidebar::-webkit-scrollbar { display: none; }

.category-item {
    padding: 16px 12px;
    text-align: center;
    font-size: 13px;
    color: var(--text-sub);
    position: relative;
    cursor: pointer;
    transition: all 0.2s;
}

.category-item.active {
    color: var(--primary-color);
    font-weight: 600;
    background: #fff5f0;
}

.category-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 20px;
    background: var(--primary-color);
    border-radius: 0 4px 4px 0;
}

/* 右侧菜品列表 (支持虚拟滚动) */
.dish-list-container {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    padding: 12px;
    /* 关键性能优化：will-change 提示浏览器优化 */
    will-change: scroll-position; 
}

.dish-section-title {
    font-size: 16px;
    font-weight: bold;
    margin: 20px 0 12px;
    color: var(--text-main);
    display: flex;
    align-items: center;
}

.dish-section-title::before {
    content: '';
    display: inline-block;
    width: 4px;
    height: 16px;
    background: var(--primary-color);
    margin-right: 8px;
    border-radius: 2px;
}

/* 菜品卡片 - 现代设计 */
.dish-card {
    display: flex;
    background: var(--card-bg);
    border-radius: var(--border-radius-md);
    padding: 12px;
    margin-bottom: 12px;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s, box-shadow 0.2s;
    /* 避免点击高亮 */
    user-select: none;
}

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

.dish-image-wrapper {
    width: 80px;
    height: 80px;
    border-radius: var(--border-radius-sm);
    overflow: hidden;
    flex-shrink: 0;
    background: #eee;
    position: relative;
}

.dish-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* 图片懒加载优化 */
    loading: lazy; 
}

.dish-info {
    flex: 1;
    margin-left: 12px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.dish-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 4px;
    /* 文本截断 */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.dish-desc {
    font-size: 12px;
    color: var(--text-sub);
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.dish-action {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.dish-price {
    color: #ff4400;
    font-weight: bold;
    font-size: 16px;
}

.dish-price::before {
    content: '¥';
    font-size: 12px;
    margin-right: 2px;
}

.add-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary-gradient);
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    cursor: pointer;
    box-shadow: var(--shadow-float);
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.add-btn:active {
    transform: scale(0.8);
}

/* --- 底部购物车栏 --- */
.cart-bar {
    position: fixed;
    bottom: calc(10px + var(--safe-area-bottom));
    left: 16px;
    right: 16px;
    height: 60px;
    background: #333;
    border-radius: 30px;
    display: flex;
    align-items: center;
    padding: 0 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    z-index: 500;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.cart-bar.hidden {
    transform: translateY(150%);
}

.cart-icon-wrapper {
    position: relative;
    width: 44px;
    height: 44px;
    background: #444;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 16px;
    border: 4px solid #333;
    top: -10px; /* 凸起效果 */
}

.cart-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff4400;
    color: white;
    font-size: 12px;
    font-weight: bold;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #333;
    transform: scale(0);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.cart-badge.show {
    transform: scale(1);
}

.cart-info {
    flex: 1;
    color: #999;
    font-size: 14px;
}

.cart-info.has-items {
    color: #fff;
}

.cart-total {
    font-size: 18px;
    font-weight: bold;
    color: #fff;
    margin-right: 12px;
}

.checkout-btn {
    background: #444;
    color: #999;
    border: none;
    padding: 8px 24px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.checkout-btn.active {
    background: var(--primary-gradient);
    color: white;
    box-shadow: 0 4px 12px rgba(255, 107, 0, 0.4);
}

/* --- 悬浮按钮 (随机选菜) --- */
.floating-btn {
    position: fixed;
    bottom: calc(80px + var(--safe-area-bottom));
    right: 20px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: var(--primary-color);
    z-index: 400;
    cursor: pointer;
    transition: transform 0.2s;
}

.floating-btn:active {
    transform: scale(0.9);
}

/* --- 搜索面板 (全屏覆盖) --- */
.search-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #fff;
    z-index: 1000;
    transform: translateY(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

.search-panel.open {
    transform: translateY(0);
}

.search-header {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid #f0f0f0;
}

.search-input-full {
    flex: 1;
    border: none;
    outline: none;
    font-size: 16px;
    padding: 8px 12px;
    background: #f5f5f5;
    border-radius: 8px;
}

.search-results {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

/* --- 动画优化类 --- */
.fade-in {
    animation: fadeIn 0.3s ease-out;
}

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

/* 飞入购物车动画 (使用 FLIP 技术或 transform) */
.fly-item {
    position: fixed;
    z-index: 9999;
    pointer-events: none;
    border-radius: 50%;
    transition: transform 0.6s cubic-bezier(0.19, 1, 0.22, 1);
}

/* 骨架屏 */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 4px;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* 移动端适配微调 */
@media (max-width: 375px) {
    .dish-image-wrapper {
        width: 70px;
        height: 70px;
    }
    .category-sidebar {
        width: 75px;
    }
}
