* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary-color: #4a90d9;
  --primary-dark: #3a7bc8;
  --success-color: #52c41a;
  --warning-color: #faad14;
  --danger-color: #ff4d4f;
  --text-color: #333;
  --text-light: #999;
  --bg-color: #f0f2f5;
  --white: #fff;
  --border-color: #e8e8e8;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg-color);
  color: var(--text-color);
}

/* 登录页面 */
.login-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
  position: relative;
}

.login-container {
  background: var(--white);
  padding: 40px;
  border-radius: 15px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
  width: 90%;
  max-width: 400px;
  margin-bottom: 60px;
}

.login-container h1 {
  text-align: center;
  margin-bottom: 30px;
  font-size: 24px;
}

.login-container .form-group {
  margin-bottom: 20px;
}

.login-container input {
  width: 100%;
  padding: 12px 15px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 16px;
}

.login-btn {
  width: 100%;
  background: var(--primary-color);
  color: var(--white);
  border: none;
  padding: 12px;
  border-radius: 8px;
  font-size: 16px;
  cursor: pointer;
}

/* 管理界面 */
.admin-app {
  min-height: 100vh;
  padding-bottom: 20px;
}

.admin-header {
  background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
  color: var(--white);
  padding: 15px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.admin-header h1 {
  font-size: 20px;
}

.logout-btn {
  background: rgba(255,255,255,0.2);
  color: var(--white);
  border: none;
  padding: 8px 15px;
  border-radius: 5px;
  cursor: pointer;
}

/* Tab 导航 */
.admin-tabs {
  display: flex;
  background: var(--white);
  border-bottom: 1px solid var(--border-color);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.admin-tabs .tab {
  flex: 1;
  padding: 15px 10px;
  text-align: center;
  text-decoration: none;
  color: var(--text-color);
  font-size: 14px;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
}

.admin-tabs .tab.active {
  color: var(--primary-color);
  border-bottom-color: var(--primary-color);
  font-weight: 600;
}

/* Tab 内容 */
.tab-content {
  display: none;
  padding: 15px;
}

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

.tab-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

.tab-header h2 {
  font-size: 18px;
}

.add-btn {
  background: var(--primary-color);
  color: var(--white);
  border: none;
  padding: 8px 15px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 14px;
  transition: opacity 0.2s;
}

.add-btn:disabled {
  background: #ccc;
  cursor: not-allowed;
  opacity: 0.6;
}

.add-btn:hover:not(:disabled) {
  background: var(--primary-dark);
}

/* 菜品管理 - 类目 Tab */
.category-tabs {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 10px 0;
  margin-bottom: 15px;
  border-bottom: 1px solid var(--border-color);
}

.category-tabs::-webkit-scrollbar {
  height: 4px;
}

.category-tabs::-webkit-scrollbar-thumb {
  background: var(--primary-color);
  border-radius: 2px;
}

.category-tab {
  flex-shrink: 0;
  background: var(--white);
  border: 1px solid var(--border-color);
  padding: 8px 16px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-color);
  transition: all 0.2s;
  white-space: nowrap;
}

.category-tab:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
}

.category-tab.active {
  background: var(--primary-color);
  border-color: var(--primary-color);
  color: var(--white);
}

/* 列表 */
.list-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.list-item {
  background: var(--white);
  border-radius: 10px;
  padding: 12px 15px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.05);
  transition: box-shadow 0.2s;
}

.list-item.sorting {
  box-shadow: 0 5px 20px rgba(74, 144, 217, 0.4);
  opacity: 0.95;
  border: 2px solid var(--primary-color);
}

.list-item-content {
  display: flex;
  gap: 12px;
  margin-bottom: 10px;
}

.list-item-cover {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 8px;
  background: var(--bg-color);
  flex-shrink: 0;
}

.list-item-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.list-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.list-item-title {
  font-weight: 600;
  font-size: 16px;
}

.list-item-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 10px;
  border-top: 1px solid var(--border-color);
  margin-top: 10px;
}

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

.action-btn.sort-handle {
  background: #f5f5f5;
  color: var(--text-color);
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  touch-action: pan-y;
  padding: 5px 10px;
  font-size: 12px;
}

.action-btn.sort-handle.sorting {
  touch-action: none;
}

.action-btn.sort-handle:active {
  cursor: grabbing;
  background: var(--primary-color);
  color: var(--white);
}

.list-item-placeholder {
  background: #f0f2f5;
  border: 2px dashed var(--primary-color);
  border-radius: 10px;
  margin: 0;
}

.list-item-status {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* 可售开关 */
.switch {
  position: relative;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
  margin: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: 0.3s;
  border-radius: 24px;
}

.switch-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.3s;
  border-radius: 50%;
}

.switch input:checked + .switch-slider {
  background-color: var(--success-color);
}

.switch input:checked + .switch-slider:before {
  transform: translateX(20px);
}

.action-btn {
  padding: 5px 12px;
  border-radius: 5px;
  font-size: 13px;
  cursor: pointer;
  border: none;
}

.action-btn.edit {
  background: var(--primary-color);
  color: var(--white);
}

.action-btn.delete {
  background: var(--danger-color);
  color: var(--white);
}

.action-btn.view {
  background: var(--success-color);
  color: var(--white);
}

/* 筛选按钮 */
.filter-btns {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-btn {
  padding: 6px 12px;
  border: 1px solid var(--border-color);
  background: var(--white);
  border-radius: 20px;
  font-size: 13px;
  cursor: pointer;
}

.filter-btn.active {
  background: var(--primary-color);
  color: var(--white);
  border-color: var(--primary-color);
}

/* 表单 */
.form-group {
  margin-bottom: 15px;
}

.form-group label {
  display: block;
  margin-bottom: 5px;
  font-size: 14px;
  color: var(--text-color);
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group input[type="password"],
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 14px;
  touch-action: pan-y;
}

.form-group input[type="file"] {
  padding: 8px 0;
}

.form-row {
  display: flex;
  gap: 15px;
}

.form-row .form-group {
  flex: 1;
}

/* 图片预览 */
.image-preview {
  margin-top: 10px;
}

.image-preview img {
  max-width: 150px;
  max-height: 150px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--border-color);
}

/* 复选框样式 */
.checkbox-label {
  display: flex;
  align-items: center;
  cursor: pointer;
  font-size: 14px;
  height: 20px;
}

.checkbox-label input[type="checkbox"] {
  width: 20px;
  height: 20px;
  margin-right: 8px;
  cursor: pointer;
  accent-color: var(--primary-color);
  vertical-align: middle;
}

.checkbox-label span {
  user-select: none;
  line-height: 20px;
}

/* 富文本编辑器 */
.rich-editor {
  border: 1px solid var(--border-color);
  border-radius: 6px;
  overflow: hidden;
}

.editor-toolbar {
  background: var(--bg-color);
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-color);
}

.editor-toolbar button {
  background: var(--white);
  border: 1px solid var(--border-color);
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
}

.editor-content {
  min-height: 150px;
  padding: 10px;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.6;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  -webkit-user-select: text;
  user-select: text;
  touch-action: pan-y;
}

.editor-content img {
  max-width: 200px;
  max-height: 150px;
  border-radius: 6px;
  margin: 8px 0;
  cursor: pointer;
}

.editor-content:focus {
  outline: none;
  background: #fafafa;
}

.rich-editor textarea {
  width: 100%;
  border: none;
  padding: 10px;
  font-family: inherit;
  font-size: 14px;
  resize: vertical;
}

/* 动态列表（原材料/可选项） */
.dynamic-list {
  margin-bottom: 10px;
}

.dynamic-item {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px;
  background: var(--bg-color);
  border-radius: 6px;
  margin-bottom: 8px;
}

.dynamic-item input {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 14px;
  touch-action: pan-y;
}

.dynamic-item input.small {
  flex: 0 0 80px;
}

.dynamic-item .remove-btn {
  background: var(--danger-color);
  color: var(--white);
  border: none;
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
}

.add-row-btn {
  background: var(--success-color);
  color: var(--white);
  border: none;
  padding: 8px 15px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  width: 100%;
}

/* 可选项组样式 */
.option-group-item {
  background: var(--bg-color);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 10px;
}

.option-group-header {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}

.option-group-header input {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 14px;
}

/* 设置表单 */
.settings-form {
  background: var(--white);
  padding: 20px;
  border-radius: 10px;
}

.save-btn {
  width: 100%;
  background: var(--primary-color);
  color: var(--white);
  border: none;
  padding: 12px;
  border-radius: 8px;
  font-size: 16px;
  cursor: pointer;
}

/* 弹窗 */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal[style*="display: none"] {
  display: none !important;
}

.modal-mask {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1;
}

.modal-content {
  position: relative;
  background: var(--white);
  width: 90%;
  max-width: 400px;
  max-height: 80vh;
  height: 80vh;
  border-radius: 15px;
  padding: 20px;
  box-sizing: border-box;
  overflow-y: scroll !important;
  -webkit-overflow-scrolling: touch !important;
  z-index: 2;
  touch-action: pan-y !important;
}

.modal-content.modal-large {
  max-width: 500px;
  max-height: 80vh;
  height: 80vh;
  overflow-y: scroll !important;
  -webkit-overflow-scrolling: touch !important;
  touch-action: pan-y !important;
}

/* 菜品详情弹窗专用样式 */
.modal-content.dish-detail-modal-content {
  height: 80vh !important;
  max-height: none !important;
  overflow-y: scroll !important;
  -webkit-overflow-scrolling: touch !important;
  padding-top: 50px !important;
  /* 隐藏滚动条 */
  scrollbar-width: none;
  -ms-overflow-style: none;
  width: 100% !important;
  max-width: 500px !important;
  pointer-events: auto !important;
  touch-action: pan-y !important;
}

.modal-content.dish-detail-modal-content::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

.dish-detail-images {
  width: 100% !important;
  margin-bottom: 15px;
}

.dish-detail-images img {
  width: 100% !important;
  height: auto;
  object-fit: cover;
  display: block;
  max-height: 300px;
  border-radius: 8px;
}

.dish-detail-info {
  width: 100%;
  padding: 0 15px;
}

.dish-detail-close-btn {
  position: absolute;
  top: 15px;
  right: 15px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(0,0,0,0.5);
  color: #fff;
  border: none;
  font-size: 24px;
  cursor: pointer;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.dish-detail-name {
  font-size: 20px !important;
  font-weight: 600 !important;
  margin-bottom: 10px !important;
  text-align: left !important;
}

.dish-detail-desc {
  font-size: 14px;
  color: #666;
  margin-bottom: 15px;
  line-height: 1.6;
}

.dish-detail-section {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid #eee;
}

.dish-detail-section h4 {
  font-size: 16px;
  margin-bottom: 15px;
  color: #333;
}

.dish-detail-steps {
  font-size: 14px;
  line-height: 1.8;
  color: #666;
}

.dish-detail-steps img {
  width: 100%;
  max-width: calc(100% - 20px);
  height: auto;
  margin: 10px 0;
  border-radius: 8px;
}

.ingredients-detail-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ingredient-detail-item {
  display: flex;
  gap: 10px;
  padding: 10px;
  background: #f9f9f9;
  border-radius: 6px;
  font-size: 14px;
}

.ingredient-detail-name {
  flex: 1;
  color: #333;
}

.ingredient-detail-qty {
  color: #ff6b35;
  font-weight: 600;
}

.modal-content h3 {
  margin-bottom: 20px;
  text-align: center;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.modal-actions button {
  flex: 1;
  padding: 12px;
  border-radius: 8px;
  font-size: 15px;
  cursor: pointer;
  border: none;
}

.cancel-btn {
  background: var(--bg-color);
  color: var(--text-color);
}

.confirm-btn {
  background: var(--primary-color);
  color: var(--white);
}

/* 订单详情 */
.order-info {
  margin-bottom: 20px;
}

.order-info-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-color);
}

.order-items {
  margin: 15px 0;
}

.order-item {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  font-size: 14px;
  align-items: flex-start;
}

.order-item > div {
  flex: 1;
}

.order-item-options {
  font-size: 12px;
  color: #999;
  margin-top: 4px;
}

.order-total {
  font-size: 18px;
  font-weight: 600;
  text-align: right;
  margin-top: 15px;
}

.order-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  flex-wrap: wrap;
}

.order-actions button {
  flex: 1;
  min-width: 80px;
  padding: 10px;
  border-radius: 6px;
  border: none;
  font-size: 14px;
  cursor: pointer;
}

.status-pending { background: var(--warning-color); color: var(--white); }
.status-confirmed { background: #1890ff; color: var(--white); }
.status-preparing { background: #722ed1; color: var(--white); }
.status-ready { background: var(--success-color); color: var(--white); }
.status-completed { background: var(--text-light); color: var(--white); }
.status-cancelled { background: var(--danger-color); color: var(--white); }

/* 状态标签 */
.status-tag {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 12px;
}

.status-tag.pending { background: #fff7e6; color: var(--warning-color); }
.status-tag.confirmed { background: #e6f7ff; color: #1890ff; }
.status-tag.preparing { background: #f9f0ff; color: #722ed1; }
.status-tag.ready { background: #f6ffed; color: var(--success-color); }
.status-tag.completed { background: #f5f5f5; color: var(--text-light); }
.status-tag.cancelled { background: #fff1f0; color: var(--danger-color); }

/* 空状态 */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-light);
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: 15px;
}

/* Toast */
.toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0,0,0,0.8);
  color: var(--white);
  padding: 12px 25px;
  border-radius: 8px;
  z-index: 2000;
}

/* 底部 Tab 栏（登录页面用） */
.login-page .tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 50px;
  background: var(--white);
  display: flex;
  border-top: 1px solid var(--border-color);
}

.login-page .tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: var(--text-light);
  font-size: 10px;
}

.login-page .tab-item.active {
  color: var(--primary-color);
}

.login-page .tab-icon {
  font-size: 20px;
  margin-bottom: 2px;
}

/* 响应式 */
@media (max-width: 480px) {
  .form-row {
    flex-direction: column;
  }

  .filter-btns {
    overflow-x: auto;
    flex-wrap: nowrap;
  }

  .order-actions {
    flex-direction: column;
  }

  .order-actions button {
    min-width: 100%;
  }
}
