/* 重置和基础样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
    overflow-x: hidden;
}

.container {
    max-width: 480px;
    margin: 0 auto;
    min-height: 100vh;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* 头部样式 */
.header {
    background: white;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 10;
}

.title {
    font-size: 24px;
    font-weight: 500;
    color: #2c3e50;
}

.settings-btn {
    background: none;
    border: none;
    padding: 8px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #6c757d;
    display: flex;
    align-items: center;
    justify-content: center;
}

.settings-btn:hover {
    background: #f1f3f4;
    color: #2c3e50;
}

.settings-btn:active {
    transform: scale(0.95);
}

/* 主内容区域 */
.main-content {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

/* 临时菜品区域 */
.temporary-dish-section {
    margin-bottom: 20px;
}

.add-temp-dish-btn {
    width: 100%;
    padding: 14px 20px;
    background: linear-gradient(135deg, #ffb347 0%, #ff9500 100%);
    color: white;
    border: none;
    border-radius: 14px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 4px 15px rgba(255, 149, 0, 0.3);
    transition: all 0.3s ease;
}

.add-temp-dish-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 149, 0, 0.4);
}

.add-temp-dish-btn:active {
    transform: scale(0.98);
}

.temp-dish-form {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease;
    opacity: 0;
    background: white;
    border-radius: 14px;
    margin-top: 0;
}

.temp-dish-form.expanded {
    max-height: 200px;
    opacity: 1;
    margin-top: 12px;
    padding: 16px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.form-row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 12px;
    margin-bottom: 12px;
}

.temp-input {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    font-size: 14px;
    transition: border-color 0.2s ease;
}

.temp-input:focus {
    outline: none;
    border-color: #ff9500;
}

.form-actions {
    display: flex;
    gap: 10px;
}

.cancel-btn, .confirm-btn {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.cancel-btn {
    background: #f8f9fa;
    color: #6c757d;
}

.cancel-btn:hover {
    background: #e9ecef;
}

.confirm-btn {
    background: linear-gradient(135deg, #ffb347 0%, #ff9500 100%);
    color: white;
}

.confirm-btn:hover {
    box-shadow: 0 4px 12px rgba(255, 149, 0, 0.3);
}

.categories-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
    max-width: 100%;
}

/* 类别卡片样式 */
.category-card {
    background: white;
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
    animation: slideInUp 0.4s ease;
}

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

.category-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.12);
}

.category-name {
    font-size: 18px;
    font-weight: 500;
    color: #2c3e50;
    margin-bottom: 12px;
    text-align: center;
}

.category-price {
    font-size: 14px;
    color: #6c757d;
    text-align: center;
    margin-bottom: 16px;
}

.counter {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

.counter-btn {
    width: 40px;
    height: 40px;
    border: 2px solid #e9ecef;
    background: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 20px;
    color: #495057;
}

.counter-btn:hover {
    background: #f8f9fa;
    border-color: #667eea;
    color: #667eea;
}

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

.counter-btn.minus {
    color: #dc3545;
}

.counter-btn.minus:hover {
    border-color: #dc3545;
    background: #fff5f5;
}

.counter-value {
    font-size: 24px;
    font-weight: 500;
    min-width: 40px;
    text-align: center;
    color: #2c3e50;
}

/* 临时菜品卡片样式 */
.category-card.temporary {
    border: 2px dashed #ffb347;
    background: linear-gradient(135deg, #fffbf7 0%, #ffffff 100%);
    position: relative;
}

.temp-badge {
    display: inline-block;
    font-size: 10px;
    background: linear-gradient(135deg, #ffb347 0%, #ff9500 100%);
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 4px;
    font-weight: 500;
}

.temp-delete-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(220, 53, 69, 0.1);
    color: #dc3545;
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.temp-delete-btn:hover {
    background: #dc3545;
    color: white;
}

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

/* 底部总计区域 */
.footer {
    background: white;
    padding: 20px;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    border-top: 1px solid #e9ecef;
}

.total-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.total-label {
    font-size: 18px;
    font-weight: 500;
    color: #2c3e50;
}

.total-amount {
    font-size: 28px;
    font-weight: 700;
    color: #667eea;
}

.clear-btn {
    width: 100%;
    padding: 12px;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.clear-btn:hover {
    background: #c82333;
}

.clear-btn:active {
    transform: scale(0.98);
}

/* 弹窗样式 */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    padding: 20px;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: white;
    border-radius: 20px;
    width: 100%;
    max-width: 400px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.modal-overlay.active .modal {
    transform: scale(1);
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-size: 20px;
    font-weight: 500;
    color: #2c3e50;
}

.close-btn {
    background: none;
    border: none;
    padding: 8px;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.2s ease;
    color: #6c757d;
}

.close-btn:hover {
    background: #f1f3f4;
}

.modal-content {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

.categories-settings {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 20px;
}

.category-setting-item {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.setting-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.setting-inputs {
    display: flex;
    gap: 12px;
}

.input-group {
    flex: 1;
}

.input-label {
    display: block;
    font-size: 12px;
    color: #6c757d;
    margin-bottom: 4px;
}

.setting-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s ease;
}

.setting-input:focus {
    outline: none;
    border-color: #667eea;
}

.delete-category-btn {
    background: #dc3545;
    color: white;
    border: none;
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.delete-category-btn:hover {
    background: #c82333;
}

.add-category-btn {
    width: 100%;
    padding: 16px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.add-category-btn:hover {
    background: #5a6fd8;
}

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

/* 响应式设计 */
@media (max-width: 480px) {
    .container {
        max-width: 100%;
    }

    .categories-container {
        grid-template-columns: 1fr;
        padding: 0;
    }

    .main-content {
        padding: 16px;
    }

    .category-card {
        margin-bottom: 16px;
    }

    .modal {
        max-width: 100%;
        margin: 20px;
    }
}

/* 移动端优化 */
@media (hover: none) {
    .counter-btn:active {
        background: #f8f9fa;
        border-color: #667eea;
        color: #667eea;
    }

    .counter-btn.minus:active {
        background: #fff5f5;
        border-color: #dc3545;
        color: #dc3545;
    }

    .settings-btn:active {
        background: #f1f3f4;
        color: #2c3e50;
    }
}

/* 无选择文本（优化移动端体验） */
.counter-value, .total-amount {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* 触摸优化 */
button {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}

/* 滚动优化 */
.modal-content::-webkit-scrollbar {
    width: 6px;
}

.modal-content::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.modal-content::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.modal-content::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}