/**
 * 装修报价系统 - 移动端设计系统 v3
 * 暖橙主题 · iOS原生风格 · 报价专用优化
 */

:root {
  /* 品牌暖橙系 */
  --pri: #D4753A;
  --pri-dark: #B85E2E;
  --pri-light: #F5EAE0;
  --pri-surface: #FDF7F2;
  /* 功能色 */
  --red: #D64040;
  --green: #3A8F66;
  --green-light: #E8F5EE;
  --gold: #C7852A;
  --gold-light: #FEF7ED;
  /* 界面 */
  --bg: #F5F3F0;
  --card: #FFFFFF;
  --text: #1B1B1B;
  --text2: #5C5652;
  --text3: #918B86;
  --text4: #C4BFBA;
  --sep: rgba(0,0,0,0.08);
  --sep-heavy: rgba(0,0,0,0.12);
  --shadow: 0 1px 3px rgba(0,0,0,0.04);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.08);
  --radius: 14px;
  --radius-sm: 10px;
  --radius-xs: 8px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --nav-h: 48px;
  --tab-h: 56px;
  --bottom-bar-h: 64px;
}

/* ============ 基础重置 ============ */
.mobile-app * { -webkit-tap-highlight-color: transparent; box-sizing: border-box; }
.mobile-app {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'PingFang SC', sans-serif;
  font-size: 15px; color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; min-height: 100vh; min-height: 100dvh;
  padding-bottom: calc(var(--bottom-bar-h) + var(--safe-bottom) + 16px);
  margin: 0;
}

/* ============ 顶部导航 ============ */
.app-nav {
  display: flex; align-items: center;
  position: sticky; top: 0; z-index: 100;
  height: calc(var(--nav-h) + var(--safe-top));
  padding: var(--safe-top) 12px 0;
  background: rgba(245,243,240,0.94);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-bottom: 0.5px solid var(--sep);
}
.app-nav-left { width: 40px; flex-shrink: 0; }
.app-nav-title {
  flex: 1; text-align: center; font-size: 17px; font-weight: 600;
  letter-spacing: -0.2px; line-height: var(--nav-h); color: var(--text);
}
.app-nav-right { width: 40px; flex-shrink: 0; text-align: right; }
.app-nav-btn {
  width: 36px; height: 36px; border-radius: 50%; border: none; background: transparent;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--pri); font-size: 18px; cursor: pointer;
}

/* ============ 底部操作栏 ============ */
.app-bottom-bar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 200;
  height: calc(var(--bottom-bar-h) + var(--safe-bottom));
  padding: 8px 16px var(--safe-bottom);
  background: rgba(255,255,255,0.96);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-top: 0.5px solid var(--sep);
  display: flex; align-items: center; gap: 12px;
}
.app-bottom-bar .price-info { flex: 1; }
.app-bottom-bar .price-total {
  font-size: 22px; font-weight: 700; color: var(--pri); line-height: 1.2;
}
.app-bottom-bar .price-unit { font-size: 12px; color: var(--text3); }
.app-bottom-bar .btn-generate {
  min-width: 120px; height: 48px; border-radius: 12px; border: none;
  background: var(--pri); color: #fff; font-size: 16px; font-weight: 600;
  cursor: pointer; transition: opacity 0.15s;
}
.app-bottom-bar .btn-generate:active { opacity: 0.8; }

/* ============ 内容区 ============ */
.app-content { padding: 10px 14px; }

/* ============ 区块标题 ============ */
.app-section-title {
  font-size: 13px; font-weight: 600; color: var(--text3);
  letter-spacing: 0.5px; padding: 12px 4px 6px;
  display: flex; align-items: center; gap: 6px;
}
.app-section-title .icon { font-size: 16px; }

/* ============ 卡片 ============ */
.app-card {
  background: var(--card); border-radius: var(--radius); padding: 16px;
  box-shadow: var(--shadow); margin-bottom: 10px;
}
.app-card:active { background: #FAF9F7; }

/* ============ 模板选择卡片（横向滑动） ============ */
.template-scroll {
  display: flex; gap: 10px; overflow-x: auto;
  padding: 4px 0 8px; scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}
.template-scroll::-webkit-scrollbar { display: none; }
.template-card {
  flex: 0 0 auto; width: 160px; padding: 16px 14px;
  border-radius: var(--radius); border: 2px solid var(--sep);
  background: var(--card); text-align: center; cursor: pointer;
  scroll-snap-align: start; transition: border-color 0.2s, box-shadow 0.2s;
}
.template-card.selected {
  border-color: var(--pri); box-shadow: 0 0 0 3px var(--pri-light);
}
.template-card .tpl-name { font-size: 16px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.template-card .tpl-price { font-size: 14px; font-weight: 700; color: var(--pri); }
.template-card .tpl-unit { font-size: 11px; color: var(--text3); }
.template-card .tpl-desc { font-size: 12px; color: var(--text2); margin-top: 6px; line-height: 1.4; }

/* ============ 户型图上传区 ============ */
.floorplan-zone {
  border: 2px dashed var(--sep-heavy); border-radius: var(--radius);
  padding: 24px 16px; text-align: center; background: var(--card);
  cursor: pointer; margin-bottom: 10px; transition: border-color 0.2s;
}
.floorplan-zone:active { border-color: var(--pri); background: var(--pri-surface); }
.floorplan-zone .upload-icon { font-size: 36px; color: var(--pri); margin-bottom: 8px; }
.floorplan-zone .upload-text { font-size: 15px; font-weight: 600; color: var(--text); }
.floorplan-zone .upload-hint { font-size: 12px; color: var(--text3); margin-top: 4px; }
.floorplan-zone .upload-actions { display: flex; gap: 10px; justify-content: center; margin-top: 12px; }
.floorplan-zone .upload-action-btn {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 10px 18px; border-radius: var(--radius-sm); border: 1px solid var(--sep);
  background: var(--bg); font-size: 12px; color: var(--text2); cursor: pointer;
}
.floorplan-zone .upload-action-btn:active { background: var(--pri-light); }

/* 识别结果卡片 */
.floorplan-result {
  background: var(--green-light); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 10px;
}
.floorplan-result .result-header {
  font-size: 14px; font-weight: 600; color: var(--green); margin-bottom: 8px;
}

/* ============ 房间折叠面板 ============ */
.room-panel {
  background: var(--card); border-radius: var(--radius);
  margin-bottom: 8px; overflow: hidden; box-shadow: var(--shadow);
}
.room-panel-header {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px; cursor: pointer;
  border-bottom: 1px solid transparent; transition: border-color 0.2s;
}
.room-panel.open .room-panel-header { border-bottom-color: var(--sep); }
.room-panel-header .room-icon {
  width: 40px; height: 40px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0;
}
.room-panel-header .room-info { flex: 1; min-width: 0; }
.room-panel-header .room-name { font-size: 15px; font-weight: 600; color: var(--text); }
.room-panel-header .room-meta { font-size: 12px; color: var(--text3); margin-top: 2px; }
.room-panel-header .room-arrow {
  font-size: 14px; color: var(--text3); transition: transform 0.2s; flex-shrink: 0;
}
.room-panel.open .room-panel-header .room-arrow { transform: rotate(180deg); }
.room-panel-body { display: none; padding: 12px 16px 16px; }
.room-panel.open .room-panel-body { display: block; }
.room-panel-body .form-row {
  display: flex; gap: 10px; margin-bottom: 10px;
}
.room-panel-body .form-col { flex: 1; }
.room-panel-body label {
  display: block; font-size: 12px; font-weight: 500; color: var(--text3); margin-bottom: 4px;
}
.room-panel-body input, .room-panel-body select {
  width: 100%; min-height: 40px; padding: 0 10px;
  border: 1px solid var(--sep); border-radius: var(--radius-xs);
  font-size: 14px; color: var(--text); background: var(--card); outline: none;
}
.room-panel-body input:focus, .room-panel-body select:focus { border-color: var(--pri); }
.room-panel-body .room-actions {
  display: flex; gap: 8px; margin-top: 12px;
}
.room-panel-body .btn-room-action {
  flex: 1; min-height: 36px; border-radius: var(--radius-xs);
  border: 1px solid var(--sep); background: var(--card);
  font-size: 13px; color: var(--text2); cursor: pointer;
}
.room-panel-body .btn-room-delete { color: var(--red); border-color: rgba(214,64,64,0.2); }

/* 添加房间按钮 */
.btn-add-room {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%; min-height: 48px; border-radius: var(--radius);
  border: 1.5px dashed var(--sep-heavy); background: transparent;
  font-size: 14px; font-weight: 500; color: var(--pri); cursor: pointer;
  margin-bottom: 10px;
}
.btn-add-room:active { background: var(--pri-surface); border-color: var(--pri); }

/* ============ 支付设置区 ============ */
.payment-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
}
.payment-item {
  display: flex; align-items: center; gap: 8px;
  padding: 12px; border-radius: var(--radius-sm); border: 1.5px solid var(--sep);
  cursor: pointer; transition: border-color 0.2s;
}
.payment-item.selected { border-color: var(--pri); background: var(--pri-surface); }
.payment-item .pay-icon { font-size: 22px; flex-shrink: 0; }
.payment-item .pay-name { font-size: 13px; font-weight: 500; color: var(--text); }

/* ============ 底部Tab栏（备用，新设计用bottom-bar替代） ============ */
.app-tabbar {
  display: flex;
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 200;
  height: calc(var(--tab-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: rgba(255,255,255,0.96);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-top: 0.5px solid var(--sep);
}
.app-tab {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px;
  color: var(--text3); font-size: 10px; font-weight: 500;
  text-decoration: none; transition: color 0.2s;
}
.app-tab.active { color: var(--pri); }
.app-tab .tab-icon { font-size: 22px; line-height: 1; }
.app-tab .tab-label { line-height: 1; }
.app-tab-center { position: relative; top: -10px; }
.app-tab-center .tab-icon-wrap {
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--pri);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 3px 12px rgba(212,117,58,0.35);
  transition: transform 0.15s;
}
.app-tab-center:active .tab-icon-wrap { transform: scale(0.92); }
.app-tab-center .tab-icon-wrap .tab-icon { font-size: 24px; color: #fff; }

/* ============ 按钮 ============ */
.app-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 20px; border-radius: var(--radius-sm);
  font-size: 15px; font-weight: 500; border: none; cursor: pointer; transition: opacity 0.15s;
}
.app-btn:active { opacity: 0.7; }
.app-btn-primary { background: var(--pri); color: #fff; }
.app-btn-outline { background: transparent; border: 1.5px solid var(--pri); color: var(--pri); }
.app-btn-block { width: 100%; }
.app-btn-lg { min-height: 50px; border-radius: 12px; font-size: 17px; font-weight: 600; }

/* ============ 标签 ============ */
.app-tag {
  display: inline-flex; padding: 4px 10px; border-radius: 100px;
  font-size: 12px; font-weight: 500; line-height: 1.4;
}
.app-tag-primary { background: var(--pri-light); color: var(--pri); }
.app-tag-green { background: var(--green-light); color: var(--green); }
.app-tag-gold { background: var(--gold-light); color: var(--gold); }

/* ============ Toast ============ */
.app-toast {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%); z-index: 9999;
  background: rgba(27,27,27,0.85); color: #fff;
  padding: 12px 22px; border-radius: 10px; font-size: 14px; font-weight: 500;
  animation: toastIn 2s ease forwards; pointer-events: none;
}
@keyframes toastIn {
  0% { opacity: 0; transform: translate(-50%,-50%) scale(0.92); }
  15% { opacity: 1; transform: translate(-50%,-50%) scale(1); }
  85% { opacity: 1; }
  100% { opacity: 0; }
}

/* ============ 数量步进器 ============ */
.app-stepper {
  display: inline-flex; align-items: center; gap: 0;
  border: 1px solid var(--sep); border-radius: var(--radius-xs); overflow: hidden;
}
.app-stepper button {
  width: 36px; height: 36px; border: none; background: var(--bg);
  font-size: 18px; color: var(--text); cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.app-stepper button:active { background: var(--pri-light); }
.app-stepper .stepper-value {
  width: 44px; text-align: center; font-size: 15px; font-weight: 600; color: var(--text);
  border-left: 1px solid var(--sep); border-right: 1px solid var(--sep);
  line-height: 36px; user-select: none;
}

/* ============ 全局Toast ============ */
.global-toast {
  position: fixed; top: calc(var(--safe-top) + 60px); left: 50%; transform: translateX(-50%); z-index: 9999;
  padding: 10px 20px; border-radius: 10px; font-size: 14px; font-weight: 500;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15); pointer-events: none;
  opacity: 0; transition: opacity 0.3s;
}
.global-toast.success { background: var(--green); color: #fff; }
.global-toast.error { background: var(--red); color: #fff; }
.global-toast.info { background: var(--pri); color: #fff; }

/* ============ 桌面/移动切换 ============ */
.app-only, .app-only-flex, .app-bottom-bar { display: none; }

@media (max-width: 768px) {
  .app-only { display: block !important; }
  .app-only-flex { display: flex !important; }
  .app-bottom-bar { display: flex !important; }

  .navbar, .site-footer, .desktop-only { display: none !important; }

  .container, .container-fluid {
    max-width: 100% !important; padding: 0 !important; margin: 0 !important;
  }
  .mobile-app-wrapper { padding: 0 0 8px; }

  /* 强制 Bootstrap 组件适配 */
  .card {
    border-radius: var(--radius) !important;
    box-shadow: var(--shadow) !important;
    margin: 0 0 10px 0 !important; border: none !important;
  }
  .btn { min-height: 44px !important; border-radius: var(--radius-sm) !important; font-size: 15px !important; }
  .btn-primary { background: var(--pri) !important; border-color: var(--pri) !important; }
  .form-control, .form-select {
    min-height: 44px !important; border-radius: var(--radius-xs) !important;
    border-color: var(--sep) !important; font-size: 15px !important;
  }
  .desktop-only { display: none !important; }
  .mobile-only { display: block !important; }
  .mobile-only-flex { display: flex !important; }

  /* 表格横向滚动 */
  .table-responsive { border-radius: var(--radius); overflow: hidden; }
  table { font-size: 13px; }

  /* 模态框全屏 */
  .modal-dialog { margin: 0 !important; max-width: 100% !important; }
  .modal-content { border-radius: 0 !important; min-height: 100vh; min-height: 100dvh; }
}

/* ============ 报价预览弹层（移动端） ============ */
@media (max-width: 768px) {
  .quote-preview-modal {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 500;
    background: var(--bg); overflow-y: auto;
    padding-bottom: calc(var(--bottom-bar-h) + var(--safe-bottom) + 20px);
  }
  .quote-preview-modal .preview-header {
    position: sticky; top: 0; z-index: 10;
    background: rgba(245,243,240,0.96); backdrop-filter: blur(20px);
    padding: calc(var(--safe-top) + 8px) 16px 8px;
    border-bottom: 0.5px solid var(--sep);
    display: flex; align-items: center; gap: 12px;
  }
  .quote-preview-modal .preview-title { flex: 1; font-size: 17px; font-weight: 600; }
  .quote-preview-modal .preview-close {
    width: 36px; height: 36px; border-radius: 50%; border: none; background: rgba(0,0,0,0.05);
    font-size: 20px; color: var(--text); cursor: pointer; display: flex; align-items: center; justify-content: center;
  }
  .quote-preview-modal .preview-body { padding: 16px; }
}

/* ============ 响应式图片和SVG ============ */
img, svg {
  max-width: 100%;
  height: auto;
}
.floorplan-preview img,
.floorplan-preview svg {
  max-width: 100%;
  height: auto;
}

/* ============ 会员页元素 ============ */
.membership-card {
  background: linear-gradient(135deg, var(--pri), var(--pri-dark));
  border-radius: var(--radius); padding: 24px 20px; color: #fff; margin-bottom: 10px;
}
.membership-card .mem-title { font-size: 18px; font-weight: 700; margin-bottom: 6px; }
.membership-card .mem-subtitle { font-size: 13px; opacity: 0.8; margin-bottom: 16px; }
.membership-card .mem-stats { display: flex; gap: 20px; }
.membership-card .mem-stat { text-align: center; }
.membership-card .mem-stat .val { font-size: 28px; font-weight: 700; }
.membership-card .mem-stat .lbl { font-size: 11px; opacity: 0.7; margin-top: 2px; }

/* 次数包卡片 */
.package-list { display: flex; flex-direction: column; gap: 8px; }
.package-item {
  display: flex; align-items: center; gap: 12px;
  padding: 16px; border-radius: var(--radius); border: 1.5px solid var(--sep);
  background: var(--card); cursor: pointer; transition: border-color 0.2s;
}
.package-item.recommended { border-color: var(--pri); background: var(--pri-surface); }
.package-item.recommended::after { content: '推荐'; font-size: 10px; background: var(--pri); color: #fff; padding: 2px 8px; border-radius: 100px; margin-left: auto; }
.package-item .pkg-info { flex: 1; }
.package-item .pkg-name { font-size: 16px; font-weight: 600; color: var(--text); }
.package-item .pkg-desc { font-size: 12px; color: var(--text3); margin-top: 2px; }
.package-item .pkg-price { font-size: 22px; font-weight: 700; color: var(--pri); }
.package-item .pkg-price .unit { font-size: 12px; font-weight: 400; color: var(--text3); }
