/* ==============================================================================
   Tiamo FoodieMgr Design System & Stylesheet (UI Style Guide Standard)
   ============================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700&display=swap');

:root {
  /* --- 品牌主色系 (Primary Indigo) --- */
  --brand-primary: #4f46e5;
  --brand-primary-hover: #4338ca;
  --brand-primary-light: #eef2ff;
  --brand-primary-glow: rgba(79, 70, 229, 0.25);

  /* --- 中性灰度色系 (Neutral Slate) --- */
  --bg-base: #f8fafc;
  --surface-card: #ffffff;
  --surface-glass: rgba(255, 255, 255, 0.88);
  --border-color: #e2e8f0;
  --border-subtle: rgba(226, 232, 240, 0.8);

  /* --- 文本色阶 (Text) --- */
  --text-main: #0f172a;
  --text-regular: #334155;
  --text-muted: #64748b;
  --text-disabled: #94a3b8;

  /* --- 状态功能色 (Feedback) --- */
  --color-success: #10b981;
  --color-warning: #f59e0b;
  --color-danger: #ef4444;
  --color-info: #0284c7;

  /* --- 顶栏预留高度 --- */
  --tiamo-bar-height: 32px;
}

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

body {
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background-color: var(--bg-base);
  color: var(--text-regular);
  min-height: 100vh;
  padding-top: var(--tiamo-bar-height);
  line-height: 1.5;
}

/* 胶囊细滚动条 */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 9999px;
}
::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* 布局骨架 */
.app-container {
  max-width: 1360px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}

/* 顶部头部 */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  padding: 1rem 1.5rem;
  background: var(--surface-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.04);
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.brand-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, #4f46e5, #3730a3);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 4px 12px var(--brand-primary-glow);
}

.brand-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.brand-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 9999px;
  background: var(--brand-primary-light);
  color: var(--brand-primary);
  border: 1px solid rgba(79, 70, 229, 0.2);
}

.brand-desc {
  font-size: 0.775rem;
  color: var(--text-muted);
}

/* 导航选项卡 (Pill Tabs) */
.nav-tabs {
  display: flex;
  align-items: center;
  background: #e2e8f0;
  padding: 4px;
  border-radius: 12px;
  gap: 4px;
}

.nav-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  border: none;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.nav-tab-btn:hover {
  color: var(--text-main);
}

.nav-tab-btn.active {
  background: #ffffff;
  color: var(--brand-primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* 工具栏与操作区 */
.toolbar-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.search-input {
  padding: 0.5rem 0.85rem 0.5rem 2.2rem;
  font-size: 0.85rem;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: #ffffff;
  color: var(--text-main);
  outline: none;
  transition: border-color 0.2s;
  width: 220px;
}
.search-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}
.search-icon {
  position: absolute;
  left: 0.75rem;
  color: var(--text-muted);
  pointer-events: none;
}
.search-input:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px var(--brand-primary-glow);
}

.select-filter {
  padding: 0.5rem 0.85rem;
  font-size: 0.85rem;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: #ffffff;
  color: var(--text-regular);
  outline: none;
  cursor: pointer;
  font-weight: 500;
}
.select-filter:focus {
  border-color: var(--brand-primary);
}

/* 按钮规范 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.55rem 1.1rem;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover {
  transform: translateY(-1px);
}
.btn:active {
  transform: translateY(0) scale(0.98);
}

.btn-primary {
  background: var(--brand-primary);
  color: #ffffff;
  box-shadow: 0 2px 8px var(--brand-primary-glow);
}
.btn-primary:hover {
  background: var(--brand-primary-hover);
  box-shadow: 0 4px 12px var(--brand-primary-glow);
}

.btn-ai {
  background: linear-gradient(135deg, #6366f1, #a855f7);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(168, 85, 247, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.2);
}
.btn-ai:hover {
  background: linear-gradient(135deg, #4f46e5, #9333ea);
  box-shadow: 0 6px 18px rgba(168, 85, 247, 0.35);
}

.btn-secondary {
  background: #ffffff;
  color: var(--text-regular);
  border: 1px solid var(--border-color);
}
.btn-secondary:hover {
  background: #f1f5f9;
  color: var(--text-main);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.08);
  color: var(--color-danger);
  border: 1px solid rgba(239, 68, 68, 0.25);
}
.btn-danger:hover {
  background: var(--color-danger);
  color: #ffffff;
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.775rem;
  border-radius: 8px;
}

/* 卡片网格 */
.grid-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 1.25rem;
}

.card {
  background: var(--surface-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 1.25rem;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  display: flex;
  flex-direction: column;
}
.card:hover {
  border-color: #cbd5e1;
  box-shadow: 0 8px 24px -4px rgba(0, 0, 0, 0.06);
  transform: translateY(-2px);
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 0.75rem;
  gap: 0.5rem;
}

.card-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.3;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 6px;
  letter-spacing: 0.02em;
}

.badge-raw {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid rgba(245, 158, 11, 0.3);
}
.badge-semi {
  background: #e0f2fe;
  color: #0369a1;
  border: 1px solid rgba(2, 132, 199, 0.3);
}
.badge-cooked {
  background: #dcfce7;
  color: #166534;
  border: 1px solid rgba(22, 101, 52, 0.3);
}
.badge-loc {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #e2e8f0;
}
.badge-expiring {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.card-body {
  flex: 1;
  margin-bottom: 1rem;
}

.meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.qty-display {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--brand-primary);
  display: flex;
  align-items: baseline;
  gap: 4px;
  margin: 0.5rem 0;
}
.qty-unit {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
}

.card-notes {
  font-size: 0.775rem;
  color: var(--text-muted);
  background: #f8fafc;
  padding: 6px 10px;
  border-radius: 8px;
  margin-top: 0.5rem;
  line-height: 1.4;
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  border-top: 1px solid var(--border-color);
  padding-top: 0.75rem;
  margin-top: auto;
  flex-wrap: wrap;
}

/* 模态弹窗系统 (Modals) */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2147483645;
  opacity: 0;
  visibility: hidden;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  padding: 1rem;
}

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

.modal-box {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 20px;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  transform: scale(0.95);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

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

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-close-btn:hover {
  background: #f1f5f9;
  color: var(--text-main);
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  max-height: calc(90vh - 140px);
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
  background: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* 表单控件 */
.form-group {
  margin-bottom: 1.15rem;
}
.form-label {
  display: block;
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--text-regular);
  margin-bottom: 0.35rem;
}
.form-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 0.6rem 0.85rem;
  font-size: 0.875rem;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: #ffffff;
  color: var(--text-main);
  outline: none;
  transition: all 0.2s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px var(--brand-primary-glow);
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

/* 周饮食计划视图 */
.week-plan-card {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.03);
}

.week-plan-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.days-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.75rem;
  overflow-x: auto;
}
@media (max-width: 1024px) {
  .days-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  }
}

.day-column {
  background: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  min-width: 150px;
}

.day-header {
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.5rem;
  margin-bottom: 0.75rem;
  text-align: center;
}
.day-name {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-main);
}
.day-date {
  font-size: 0.725rem;
  color: var(--text-muted);
}

.meal-slot {
  margin-bottom: 0.75rem;
}
.slot-title {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 0.25rem;
  display: flex;
  align-items: center;
  gap: 4px;
}
.dish-tag {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-regular);
  margin-bottom: 4px;
  display: block;
}
.dish-tag.is-wanted {
  border-color: #a855f7;
  color: #7e22ce;
  background: #faf5ff;
}

/* 采购清单 (Shopping List) */
.shopping-card {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.03);
}

.shopping-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  margin-bottom: 0.65rem;
  background: #ffffff;
  transition: all 0.2s;
}
.shopping-item:hover {
  border-color: #cbd5e1;
  background: #f8fafc;
}

.shopping-item-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.shopping-item-qty {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--brand-primary);
}
.shopping-item-desc {
  font-size: 0.775rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

/* Toast 提示 */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 2147483647;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.toast {
  padding: 0.75rem 1.25rem;
  border-radius: 12px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #ffffff;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  animation: toastIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.toast-success { background: #10b981; }
.toast-error { background: #ef4444; }
.toast-info { background: #4f46e5; }
@keyframes toastIn {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* 空状态 */
.empty-state {
  text-align: center;
  padding: 3.5rem 1.5rem;
  color: var(--text-muted);
}
.empty-icon {
  margin: 0 auto 1rem;
  color: #cbd5e1;
}
.empty-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-regular);
  margin-bottom: 0.5rem;
}
.empty-desc {
  font-size: 0.85rem;
  max-width: 400px;
  margin: 0 auto 1.5rem;
}

/* ==============================================================================
   AI 伴随式协同规划工作台 & 拖拽排餐微交互
   ============================================================================== */

.modal-box-wide {
  max-width: 1260px !important;
  width: 96vw !important;
  height: 92vh !important;
  max-height: 92vh !important;
}

.ai-workspace-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 1.25rem;
  height: 100%;
  min-height: 520px;
}

@media (max-width: 992px) {
  .ai-workspace-layout {
    grid-template-columns: 1fr;
    height: auto;
  }
}

.ai-plan-panel {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding-right: 0.5rem;
  max-height: calc(92vh - 140px);
}

.ai-chat-panel {
  background: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.03);
  height: calc(92vh - 140px);
}

.ai-chat-header {
  padding: 0.85rem 1rem;
  background: #ffffff;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ai-chat-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.ai-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 0.7rem;
  font-weight: 700;
}
.ai-status-ready {
  background: #ecfdf5;
  color: #047857;
  border: 1px solid rgba(16, 185, 129, 0.25);
}
.ai-status-fallback {
  background: #fffbeb;
  color: #b45309;
  border: 1px solid rgba(245, 158, 11, 0.25);
}

.ai-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.chat-bubble {
  max-width: 90%;
  padding: 0.75rem 0.95rem;
  border-radius: 14px;
  font-size: 0.825rem;
  line-height: 1.5;
  word-break: break-word;
}

.chat-bubble-ai {
  align-self: flex-start;
  background: #ffffff;
  border: 1px solid var(--border-color);
  color: var(--text-main);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
}

.chat-bubble-user {
  align-self: flex-end;
  background: var(--brand-primary);
  color: #ffffff;
  border-bottom-right-radius: 4px;
}

.chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.5rem 1rem;
  background: #ffffff;
  border-top: 1px solid var(--border-color);
}

.chat-suggest-btn {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 9999px;
  font-size: 0.725rem;
  padding: 3px 10px;
  color: var(--text-regular);
  cursor: pointer;
  transition: all 0.15s;
  text-align: left;
}
.chat-suggest-btn:hover {
  background: #e2e8f0;
  color: var(--brand-primary);
}

.chat-input-area {
  padding: 0.75rem 1rem;
  background: #ffffff;
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.chat-input {
  flex: 1;
  padding: 0.55rem 0.85rem;
  font-size: 0.825rem;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  outline: none;
  background: #f8fafc;
}
.chat-input:focus {
  background: #ffffff;
  border-color: var(--brand-primary);
}

/* 拖拽排餐微交互 */
.draggable-dish {
  cursor: grab;
  position: relative;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  user-select: none;
}
.draggable-dish:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  border-color: var(--brand-primary);
}
.draggable-dish:active {
  cursor: grabbing;
  opacity: 0.6;
}

.dish-del-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 4px;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.dish-del-btn:hover {
  color: var(--color-danger);
  background: rgba(239, 68, 68, 0.1);
}

.meal-slot {
  min-height: 48px;
  border-radius: 8px;
  transition: all 0.2s;
  padding: 4px;
}
.meal-slot.drag-over {
  background: #eef2ff !important;
  border: 2px dashed var(--brand-primary) !important;
}

.btn-add-slot-dish {
  background: transparent;
  border: 1px dashed #cbd5e1;
  border-radius: 6px;
  width: 100%;
  padding: 3px 0;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
  margin-top: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
}
.btn-add-slot-dish:hover {
  border-color: var(--brand-primary);
  color: var(--brand-primary);
  background: #ffffff;
}

.inline-dish-input-box {
  display: flex;
  gap: 4px;
  margin-top: 4px;
}
.inline-dish-input {
  flex: 1;
  font-size: 0.75rem;
  padding: 3px 6px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  outline: none;
}
.inline-dish-input:focus {
  border-color: var(--brand-primary);
}

