/* 基础样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Microsoft YaHei', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* 头部样式 */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.95);
    padding: 20px 30px;
    border-radius: 15px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    margin-bottom: 30px;
    backdrop-filter: blur(10px);
}

header h1 {
    color: #2c3e50;
    font-size: 2rem;
    font-weight: bold;
}

.nav-buttons {
    display: flex;
    align-items: center;
    gap: 15px;
}

.admin-link {
    padding: 12px;
    background: #34495e;
    border-radius: 50%;
    font-size: 1.2rem;
    text-decoration: none;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(52, 73, 94, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
}

.admin-link:hover {
    background: #2c3e50;
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(52, 73, 94, 0.4);
}

.cart-icon {
    position: relative;
    cursor: pointer;
    padding: 15px;
    background: #e74c3c;
    border-radius: 50%;
    font-size: 1.5rem;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(231, 76, 60, 0.3);
}

.cart-icon:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(231, 76, 60, 0.4);
}

.cart-count {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #fff;
    color: #e74c3c;
    border-radius: 50%;
    width: 25px;
    height: 25px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: bold;
    border: 2px solid #e74c3c;
}

/* 主要内容区域 */
main {
    position: relative;
}

/* 菜品展示区域 */
.dishes-container {
    padding: 20px 0;
}

.loading {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px;
    font-size: 1.2rem;
    color: #fff;
}

/* 菜品分类标题 */
.category-title {
    font-size: 1.3rem;
    font-weight: bold;
    color: #fff;
    margin: 25px 0 15px 0;
    padding: 12px 20px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    gap: 10px;
}

/* 菜品列表容器 */
.category-dishes {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
}

/* 菜品卡片 - 列表式布局 */
.dish-card {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 12px 15px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: all 0.2s ease;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 80px;
    cursor: pointer;
}

.dish-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    background: rgba(255, 255, 255, 0.98);
}

/* 菜品图片区域 - 缩略图 */
.dish-image {
    width: 60px;
    height: 60px;
    border-radius: 8px;
    overflow: hidden;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.dish-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.2s ease;
}

.dish-image img:hover {
    transform: scale(1.1);
}

.dish-icon {
    font-size: 1.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    color: #666;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 8px;
}

/* 菜品信息区域 */
.dish-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0; /* 防止文字溢出 */
}

.dish-name {
    font-size: 1.1rem;
    font-weight: bold;
    color: #2c3e50;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dish-description {
    color: #7f8c8d;
    line-height: 1.4;
    font-size: 0.85rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

/* 价格单独区域 */
.dish-price {
    font-size: 1.2rem;
    font-weight: bold;
    color: #e74c3c;
    margin-right: 12px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    min-width: 80px;
    justify-content: flex-end;
}

.dish-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

/* 价格和操作区域容器 */
.dish-price-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.quantity-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.quantity-btn {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 50%;
    background: #3498db;
    color: white;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.quantity-btn:hover {
    background: #2980b9;
    transform: scale(1.1);
}

.quantity-btn:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
    transform: none;
}

.quantity-display {
    font-size: 1rem;
    font-weight: bold;
    min-width: 25px;
    text-align: center;
}

.add-to-cart-btn {
    background: #27ae60;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 15px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: bold;
    white-space: nowrap;
}

.add-to-cart-btn:hover {
    background: #229954;
    transform: scale(1.05);
}

/* 购物车侧边栏 */
.cart-sidebar {
    position: fixed;
    top: 0;
    right: -450px;
    width: 450px;
    height: 100vh;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: -5px 0 25px rgba(0, 0, 0, 0.2);
    transition: right 0.3s ease;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    backdrop-filter: blur(20px);
    overflow: hidden;
}

.cart-sidebar.active {
    right: 0;
}

.cart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-bottom: 1px solid #eee;
    background: rgba(52, 152, 219, 0.1);
}

.cart-header h3 {
    font-size: 1.4rem;
    color: #2c3e50;
}

.close-btn {
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: #e74c3c;
    padding: 5px;
    transition: all 0.3s ease;
}

.close-btn:hover {
    color: #c0392b;
    transform: scale(1.2);
}

.cart-items {
    flex: 1;
    overflow-y: auto;
    padding: 20px 25px;
    min-height: 0;
    max-height: calc(100vh - 200px);
}

.cart-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 0;
    border-bottom: 1px solid #eee;
}

.cart-item:last-child {
    border-bottom: none;
}

.cart-item-info {
    flex: 1;
}

.cart-item-name {
    font-weight: bold;
    color: #2c3e50;
    margin-bottom: 5px;
}

.cart-item-price {
    color: #e74c3c;
    font-weight: bold;
}

.cart-item-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.cart-item-controls .quantity-btn {
    width: 30px;
    height: 30px;
    font-size: 1rem;
}

.cart-item-controls .quantity-display {
    min-width: 25px;
    font-size: 1rem;
}

.remove-item-btn {
    background: #e74c3c;
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 15px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.remove-item-btn:hover {
    background: #c0392b;
}

.cart-footer {
    padding: 25px;
    border-top: 1px solid #eee;
    background: rgba(52, 152, 219, 0.05);
    flex-shrink: 0;
    overflow-y: auto;
    max-height: 50vh;
}

.cart-total {
    font-size: 1.4rem;
    font-weight: bold;
    color: #2c3e50;
    margin-bottom: 20px;
    text-align: center;
    padding: 15px;
    background: rgba(231, 76, 60, 0.1);
    border-radius: 10px;
}

.customer-info {
    margin-bottom: 20px;
}

.customer-info input,
.customer-info textarea {
    width: 100%;
    padding: 12px 15px;
    margin-bottom: 10px;
    border: 2px solid #ddd;
    border-radius: 25px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
    background: rgba(255, 255, 255, 0.9);
}

.customer-info input:focus,
.customer-info textarea:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 10px rgba(52, 152, 219, 0.2);
}

.customer-info textarea {
    resize: vertical;
    min-height: 80px;
    border-radius: 15px;
}

.submit-btn {
    width: 100%;
    background: linear-gradient(45deg, #e74c3c, #f39c12);
    color: white;
    border: none;
    padding: 15px;
    border-radius: 25px;
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(231, 76, 60, 0.3);
}

.submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(231, 76, 60, 0.4);
}

.submit-btn:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* 遮罩层 */
.cart-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.cart-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* 空购物车样式 */
.empty-cart {
    text-align: center;
    padding: 40px 20px;
    color: #7f8c8d;
}

.empty-cart-icon {
    font-size: 3rem;
    margin-bottom: 15px;
}

/* 图片放大浏览模态框 */
.image-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.image-modal.active {
    opacity: 1;
    visibility: visible;
}

.image-modal-content {
    position: relative;
    max-width: 90%;
    max-height: 90%;
    background: white;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    transform: scale(0.7);
    transition: transform 0.3s ease;
}

.image-modal.active .image-modal-content {
    transform: scale(1);
}

.image-modal-header {
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.image-modal-title {
    font-size: 1.3rem;
    font-weight: bold;
    margin: 0;
}

.image-modal-close {
    background: none;
    border: none;
    color: white;
    font-size: 2rem;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.image-modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.image-modal-body {
    padding: 0;
    display: flex;
    flex-direction: column;
}

.image-modal-img {
    width: 100%;
    height: auto;
    max-height: 400px;
    object-fit: cover;
}

.image-modal-info {
    padding: 20px;
    background: #f8f9fa;
}

.image-modal-description {
    color: #666;
    line-height: 1.6;
    margin-bottom: 10px;
}

.image-modal-price {
    font-size: 1.5rem;
    font-weight: bold;
    color: #e74c3c;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    header {
        padding: 15px 20px;
    }
    
    header h1 {
        font-size: 1.5rem;
    }
    
    .cart-sidebar {
        width: 100%;
        right: -100%;
    }
    
    .cart-sidebar.active {
        right: 0;
    }
    
    /* 移动端购物车内容区域调整 */
    .cart-items {
        max-height: calc(100vh - 320px);
        padding: 15px 20px;
    }
    
    .cart-footer {
        padding: 20px;
        max-height: 60vh;
    }
    
    .cart-header {
        padding: 15px 20px;
        flex-shrink: 0;
    }
    
    .dish-card {
        padding: 10px 12px;
        gap: 10px;
        min-height: 70px;
    }
    
    .dish-image {
        width: 50px;
        height: 50px;
    }
    
    .dish-icon {
        font-size: 1.5rem;
    }
    
    .category-title {
        font-size: 1.2rem;
        padding: 10px 15px;
        margin: 20px 0 10px 0;
    }
    
    .dish-name {
        font-size: 1rem;
    }
    
    .dish-description {
        font-size: 0.8rem;
    }
    
    .dish-price {
        font-size: 1.1rem;
    }
    
    .add-to-cart-btn {
        padding: 5px 10px;
        font-size: 0.8rem;
    }
    
    .quantity-btn {
        width: 26px;
        height: 26px;
        font-size: 0.9rem;
    }
    
    .image-modal-content {
        max-width: 95%;
        max-height: 95%;
    }
    
    .image-modal-header {
        padding: 15px;
    }
    
    .image-modal-title {
        font-size: 1.1rem;
    }
    
    .image-modal-img {
        max-height: 300px;
    }
    
    .image-modal-info {
        padding: 15px;
    }
}

@media (max-width: 480px) {
    .dish-card {
        padding: 12px;
        gap: 10px;
        min-height: auto;
    }
    
    .dish-image {
        width: 45px;
        height: 45px;
    }
    
    .dish-icon {
        font-size: 1.4rem;
    }
    
    .dish-info {
        flex: 1;
        min-width: 0;
    }
    
    .dish-name {
        font-size: 1rem;
        margin-bottom: 3px;
    }
    
    .dish-description {
        font-size: 0.8rem;
        -webkit-line-clamp: 1;
        margin-bottom: 4px;
    }
    
    /* 移动端价格和操作区域重新布局 */
    .dish-price-actions {
        flex-direction: column;
        align-items: flex-end;
        gap: 8px;
        min-width: 90px;
    }
    
    .dish-price {
        font-size: 1.1rem;
        margin-right: 0;
        min-width: auto;
        order: 1;
    }
    
    .dish-actions {
        order: 2;
        gap: 6px;
    }
    
    .add-to-cart-btn {
        padding: 4px 8px;
        font-size: 0.75rem;
        white-space: nowrap;
    }
    
    .quantity-btn {
        width: 24px;
        height: 24px;
        font-size: 0.8rem;
    }
    
    .quantity-display {
        font-size: 0.9rem;
        min-width: 20px;
    }
    
    .image-modal-img {
        max-height: 250px;
    }
    
    /* 小屏幕购物车特殊调整 */
    .cart-items {
        max-height: calc(100vh - 350px);
        padding: 12px 15px;
    }
    
    .cart-footer {
        padding: 15px;
        max-height: 65vh;
    }
    
    .cart-header {
        padding: 12px 15px;
    }
    
    .customer-info input,
    .customer-info textarea {
        padding: 10px 12px;
        margin-bottom: 8px;
        font-size: 0.9rem;
    }
    
    .customer-info textarea {
        min-height: 60px;
    }
    
    .submit-btn {
        padding: 12px;
        font-size: 1.1rem;
    }
    
    .cart-total {
        font-size: 1.2rem;
        padding: 12px;
        margin-bottom: 15px;
    }
}

/* 极小屏幕设备特殊处理 */
@media (max-width: 360px) {
    .cart-items {
        max-height: calc(100vh - 380px);
        padding: 10px 12px;
    }
    
    .cart-footer {
        padding: 12px;
        max-height: 70vh;
    }
    
    .customer-info input,
    .customer-info textarea {
        padding: 8px 10px;
        font-size: 0.85rem;
    }
    
    .submit-btn {
        padding: 10px;
        font-size: 1rem;
    }
}

/* 通用移动端购物车优化 */
@media (max-width: 768px) and (orientation: portrait) {
    .cart-sidebar {
        /* 确保购物车可以在竖屏上正常显示 */
        height: 100vh;
        height: 100dvh; /* 使用动态视口高度 */
    }
    
    .cart-items {
        /* 防止内容被截断 */
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
    }
    
    .cart-footer {
        /* 防止底部被截断 */
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* 移动端滚动条样式 */
    .cart-items::-webkit-scrollbar,
    .cart-footer::-webkit-scrollbar {
        width: 3px;
    }
    
    .cart-items::-webkit-scrollbar-track,
    .cart-footer::-webkit-scrollbar-track {
        background: transparent;
    }
    
    .cart-items::-webkit-scrollbar-thumb,
    .cart-footer::-webkit-scrollbar-thumb {
        background: rgba(0, 0, 0, 0.2);
        border-radius: 2px;
    }
}