/* responsive.css - 响应式覆盖层，在所有现有CSS之后加载 */
/* 作者：余嘉华 | 作品：对照品自动查询与库房指引 */

/* ===== 基础变量与工具 ===== */
:root {
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

/* ===== 页头重构 ===== */
.app-header {
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 12px;
}

.brand {
  min-width: 0;
  flex: 1 1 auto;
}

.brand h1 {
  font-size: 16px;
}

.brand p {
  font-size: 11px;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  color: var(--primary-deep);
  background: linear-gradient(135deg, #ccfbf1, #99f6e4);
  text-decoration: none;
  white-space: nowrap;
  min-height: 44px;
  transition: opacity 0.2s;
}

.nav-link:hover {
  opacity: 0.85;
}

.ghost-btn {
  min-height: 44px;
  padding: 8px 12px;
  font-size: 13px;
}

/* ===== 容器与栅格 ===== */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  min-width: 0;
}

.left-col,
.right-col {
  min-width: 0;
  overflow-wrap: break-word;
}

/* ===== 操作按钮区 ===== */
.action-buttons {
  display: flex;
  gap: 8px;
}

.action-btn {
  flex: 1 1 0;
  min-width: 0;
  padding: 12px 6px;
  font-size: 14px;
  min-height: 52px;
}

.action-btn svg {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

/* ===== 步骤条 ===== */
.steps {
  gap: 6px;
  padding: 6px 0;
}

.step {
  font-size: 12px;
}

.step-line {
  width: 16px;
}

/* ===== 输入框最小字号16px防缩放 ===== */
input[type="text"],
input[type="date"],
textarea,
.batch-textarea,
.batch-input,
.input-with-unit input,
.input-with-unit select,
.global-row input {
  font-size: 16px;
}

/* ===== 项目与用量输入区 ===== */
.inputs-row {
  grid-template-columns: 1fr;
  gap: 10px;
}

.input-with-unit {
  flex-wrap: wrap;
}

.input-with-unit input {
  min-width: 0;
  flex: 1 1 auto;
}

.input-with-unit select {
  flex-shrink: 0;
}

/* ===== 全局行 ===== */
.global-row {
  flex-wrap: wrap;
}

.global-row input {
  min-width: 0;
  flex: 1 1 auto;
}

#apply-all-project {
  flex-shrink: 0;
}

/* ===== 预览卡片 ===== */
.preview-card {
  padding: 14px;
}

.preview-text {
  font-size: 13px;
  max-height: 200px;
}

/* ===== 底部固定栏安全区 ===== */
.bottom-bar {
  padding: 8px 12px calc(8px + var(--safe-bottom));
  gap: 8px;
}

.bottom-btn {
  min-height: 48px;
  font-size: 14px;
  padding: 10px 8px;
}

/* ===== 弹窗修复 ===== */
.modal-overlay[hidden] {
  display: none !important;
}

.modal-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-card {
  max-height: 85vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  width: 100%;
}

/* ===== 内容网格最小宽度 ===== */
.content-grid {
  min-width: 0;
}

.info-row {
  min-width: 0;
}

.info-value {
  word-break: break-word;
  overflow-wrap: break-word;
}

/* ===== 来源链接长文本 ===== */
.source-link {
  word-break: break-all;
  display: inline;
}

/* ===== 状态文本 ===== */
.status-badge {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===== 项目候选芯片 ===== */
.project-candidates {
  gap: 6px;
}

.suggestion-chip {
  font-size: 12px;
  padding: 6px 10px;
}

/* ===== 批量弹窗适配 ===== */
.batch-modal.active {
  padding: 0;
}

.batch-card {
  border-radius: 0;
  max-width: 100%;
  min-height: 100vh;
}

/* ===== 响应式断点 ===== */

/* 320px - 基础小屏 */
@media (min-width: 320px) {
  .container {
    padding: 10px;
  }
  
  .action-btn {
    font-size: 13px;
    padding: 10px 4px;
  }
  
  .step {
    font-size: 11px;
  }
  
  .step-dot {
    width: 20px;
    height: 20px;
    font-size: 11px;
  }
}

/* 360px */
@media (min-width: 360px) {
  .container {
    padding: 12px;
  }
  
  .action-btn {
    font-size: 14px;
  }
  
  .brand h1 {
    font-size: 17px;
  }
}

/* 390px */
@media (min-width: 390px) {
  .app-header {
    padding: 12px 14px;
  }
  
  .action-btn {
    padding: 12px 6px;
  }
  
  .bottom-btn {
    font-size: 15px;
  }
}

/* 412px */
@media (min-width: 412px) {
  .container {
    padding: 14px;
  }
  
  .steps {
    gap: 8px;
  }
  
  .step {
    font-size: 12px;
  }
}

/* 768px - 平板横屏/小桌面 */
@media (min-width: 768px) {
  .container {
    grid-template-columns: 1.2fr 0.8fr;
    gap: 20px;
    padding: 20px;
  }
  
  .left-col {
    display: flex;
    flex-direction: column;
    gap: 16px;
  }
  
  .right-col {
    position: sticky;
    top: 80px;
    align-self: start;
  }
  
  .preview-card {
    padding: 20px;
  }
  
  .preview-text {
    max-height: 300px;
  }
  
  .inputs-row {
    grid-template-columns: 1fr 1fr;
  }
  
  .batch-modal.active {
    padding: 20px;
  }
  
  .batch-card {
    border-radius: 12px;
    min-height: auto;
  }
  
  .modal-overlay {
    padding: 24px;
  }
  
  .modal-card {
    max-height: 80vh;
  }
}

/* 1024px - 标准桌面 */
@media (min-width: 1024px) {
  .container {
    grid-template-columns: 1.3fr 0.7fr;
    gap: 24px;
    padding: 24px;
  }
  
  .app-header {
    padding: 14px 24px;
  }
  
  .brand h1 {
    font-size: 18px;
  }
  
  .brand p {
    font-size: 12px;
  }
  
  .header-nav {
    gap: 10px;
  }
  
  .action-btn {
    min-height: 56px;
  }
  
  .preview-card {
    padding: 24px;
  }
}

/* 1440px - 大屏桌面 */
@media (min-width: 1440px) {
  .container {
    grid-template-columns: 1.4fr 0.6fr;
    gap: 32px;
    max-width: 1280px;
    padding: 28px 32px;
  }
  
  .preview-card {
    padding: 28px;
  }
  
  .preview-text {
    font-size: 14px;
    max-height: 360px;
  }
}

/* ===== 特殊适配 ===== */

/* 小屏弹窗滚动 */
@media (max-width: 767px) {
  .modal-card {
    max-height: 90vh;
    margin: auto;
  }
  
  .batch-card {
    border-radius: 0;
  }
  
  .batch-body {
    padding: 16px;
  }
  
  .batch-table {
    font-size: 12px;
  }
  
  .batch-table th,
  .batch-table td {
    padding: 10px 12px;
  }
}

/* 超小屏紧凑 */
@media (max-width: 359px) {
  .brand h1 {
    font-size: 15px;
  }
  
  .brand p {
    font-size: 10px;
  }
  
  .nav-link,
  .ghost-btn {
    font-size: 12px;
    padding: 6px 10px;
    min-height: 40px;
  }
  
  .action-btn {
    font-size: 12px;
    padding: 8px 2px;
    min-height: 48px;
  }
  
  .action-btn svg {
    width: 20px;
    height: 20px;
  }
  
  .step {
    font-size: 10px;
  }
  
  .step-dot {
    width: 18px;
    height: 18px;
    font-size: 10px;
  }
  
  .bottom-btn {
    font-size: 13px;
    min-height: 44px;
  }
  
  .preview-card {
    padding: 12px;
  }
  
  .global-row {
    gap: 6px;
  }
  
  .inputs-row {
    gap: 8px;
  }
}

/* 横屏安全区 */
@supports (padding: max(0px)) {
  .app-header {
    padding-left: max(12px, var(--safe-left));
    padding-right: max(12px, var(--safe-right));
    padding-top: max(10px, var(--safe-top));
  }
  
  .bottom-bar {
    padding-left: max(12px, var(--safe-left));
    padding-right: max(12px, var(--safe-right));
  }
}

/* 减少动画偏好 */
@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}

/* 1. 动态卡片项目输入框样式统一 */
.input-group > input[type="text"] {
  font-size: 16px;
  min-height: 44px;
  height: 44px;
  border: 1px solid #ccc;
  border-radius: 6px;
  padding: 8px 12px;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  -webkit-appearance: none;
  appearance: none;
}

/* 2. 用量与单位保持同一行 */
.input-with-unit {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  width: 100%;
  min-width: 0;
}

.input-with-unit > input {
  flex: 1 1 0;
  width: 0;
  min-width: 0;
}

.input-with-unit > select,
.input-with-unit > .unit-label,
.input-with-unit > .unit {
  flex: 0 0 70px;
  width: 70px;
  min-width: 70px;
  max-width: 70px;
}


.container {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}

@media (min-width: 768px) {
  .container {
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.8fr);
  }
}

@media (min-width: 1024px) {
  .container {
    grid-template-columns: minmax(0, 1.3fr) minmax(0, 0.7fr);
  }
}

@media (min-width: 1440px) {
  .container {
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 0.6fr);
  }
}

.inputs-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}

@media (min-width: 768px) {
  .inputs-row {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
}

.input-group {
  min-width: 0;
}

.nav-link,
.ghost-btn {
  min-height: 44px;
}

.steps {
  display: flex;
  flex-wrap: wrap;
}

.step {
  font-size: max(12px, inherit);
  white-space: normal;
}

.step-line {
  display: none;
}

@media (min-width: 768px) {
  .step-line {
    display: block;
  }
}

body {
  padding-bottom: calc(88px + env(safe-area-inset-bottom, 0px));
}

.bottom-bar {
  padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
}

.amount-hint{display:block;font-size:11px;color:#6b7878;line-height:1.5;margin-top:4px}

/* Partial label recognition */
.batch-suggestions {margin:8px 0 12px;overflow-wrap:anywhere}
.batch-suggestions[hidden] {display:none}
.batch-suggestions p {margin:0 0 8px;color:#637075;font-size:13px}
.batch-suggestions button {display:flex;width:100%;gap:8px;align-items:center;justify-content:space-between;text-align:left;border:1px solid #badbd5;background:#f2faf7;color:#20544a;border-radius:10px;padding:11px 12px;margin:6px 0;font:inherit;cursor:pointer}
.batch-suggestions b {flex-shrink:0;font-size:12px}
.item-actions {flex-wrap:wrap}

.batch-suggestions small{display:block;color:#617a73;font-size:12px;line-height:1.5;margin-top:3px}

.photo-open{display:flex;flex-direction:column;align-items:center;gap:3px;border:0;background:transparent;color:#087d78;padding:0;cursor:zoom-in;font:inherit}.photo-open span{font-size:10px;white-space:nowrap}.photo-open:focus-visible{outline:3px solid #2ea69e;outline-offset:3px;border-radius:8px}
