/* ============================================================
   EcosaVision · style.css — Apple redesign
   Dynamic component styles (layout handled by Tailwind)
   ============================================================ */

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

::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d1d6; border-radius: 2px; }

/* ── Room Mode Toggle ───────────────────────────────────────── */
.room-mode-toggle {
  display: flex;
  gap: 3px;
  background: rgba(0,0,0,0.04);
  border-radius: 10px;
  padding: 3px;
  margin-bottom: 10px;
}

.room-mode-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 6px 10px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: #86868b;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", sans-serif;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all .2s;
  white-space: nowrap;
}

.room-mode-btn.active {
  background: #fff;
  color: #1d1d1f;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

.room-mode-btn:hover:not(.active) { color: #3c3c43; }
.room-mode-btn svg { flex-shrink: 0; }

/* ── Prompt Textarea ────────────────────────────────────────── */
.prompt-textarea {
  width: 100%;
  border: 1.5px solid #e5e5ea;
  border-radius: 12px;
  padding: 11px 13px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", sans-serif;
  font-size: 13px;
  color: #1d1d1f;
  background: #fafafa;
  resize: vertical;
  outline: none;
  transition: border-color .2s, background .2s;
  line-height: 1.55;
}

.prompt-textarea:focus {
  border-color: #0071e3;
  background: #fff;
}

.prompt-textarea::placeholder { color: #aeaeb2; }

/* ── Section Labels ─────────────────────────────────────────── */
.section-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: #86868b;
  text-transform: uppercase;
  margin-bottom: 10px;
}

/* ── Upload Zones ────────────────────────────────────────────── */
.upload-section { margin-bottom: 20px; }

.upload-zone {
  border: 1.5px dashed #d1d1d6;
  border-radius: 16px;
  padding: 22px 18px;
  text-align: center;
  cursor: pointer;
  transition: all .2s;
  background: #fafafa;
  position: relative;
  overflow: hidden;
}

.upload-zone:hover {
  border-color: #0071e3;
  background: rgba(0,113,227,0.03);
}

.upload-zone.has-image {
  border-style: solid;
  border-color: #e5e5ea;
  padding: 0;
  aspect-ratio: 4 / 3;
}

.upload-zone.has-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 14px;
  display: block;
}

.upload-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.upload-icon {
  width: 40px;
  height: 40px;
  margin: 0 auto 10px;
  background: #f2f2f7;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.upload-icon svg {
  width: 20px;
  height: 20px;
  stroke: #86868b;
}

.upload-hint {
  font-size: 12px;
  color: #86868b;
  line-height: 1.6;
}

.upload-hint strong {
  color: #3c3c43;
  font-weight: 500;
  display: block;
  margin-bottom: 2px;
}

.clear-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 24px;
  height: 24px;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(4px);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  transition: background .15s;
}

.clear-btn:hover { background: rgba(255,59,48,0.82); }

.clear-btn svg {
  width: 10px;
  height: 10px;
  stroke: white;
  fill: none;
  stroke-width: 2.5;
}

/* ── Furniture Multi-upload Grid ─────────────────────────────── */
.furniture-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.furniture-thumb {
  width: 72px;
  height: 72px;
  border-radius: 10px;
  overflow: hidden;
  position: relative;
  border: 1px solid #e5e5ea;
  flex-shrink: 0;
}

.furniture-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.furniture-remove-btn {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 18px;
  height: 18px;
  background: rgba(0,0,0,0.5);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity .15s;
  padding: 0;
}

.furniture-thumb:hover .furniture-remove-btn { opacity: 1; }

.furniture-remove-btn svg {
  width: 8px;
  height: 8px;
  stroke: white;
  fill: none;
  stroke-width: 2.5;
}

.add-furniture-btn {
  width: 72px;
  height: 72px;
  border: 1.5px dashed #d1d1d6;
  border-radius: 10px;
  background: #fafafa;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: #86868b;
  font-size: 11px;
  transition: all .2s;
  flex-shrink: 0;
}

.add-furniture-btn:hover {
  border-color: #0071e3;
  color: #0071e3;
  background: rgba(0,113,227,0.03);
}

.add-furniture-btn svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
}

.item-count {
  font-weight: 400;
  color: #aeaeb2;
  font-size: 11px;
}

/* ── Background Selector ─────────────────────────────────────── */
.bg-selector {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}

.bg-option {
  border: 1.5px solid #e5e5ea;
  border-radius: 12px;
  padding: 8px;
  cursor: pointer;
  text-align: center;
  font-size: 11px;
  color: #86868b;
  transition: all .2s;
  background: #fafafa;
  user-select: none;
}

.bg-option.active {
  border-color: #0071e3;
  color: #0071e3;
  background: rgba(0,113,227,0.05);
}

.bg-option:hover:not(.active) {
  border-color: #c7c7cc;
  color: #3c3c43;
}

.bg-preview {
  height: 28px;
  border-radius: 6px;
  margin-bottom: 6px;
  border: 1px solid #e5e5ea;
}

.bg-white { background: #fff; }

.bg-check {
  background-image:
    linear-gradient(45deg,  #c7c7cc 25%, transparent 25%),
    linear-gradient(-45deg, #c7c7cc 25%, transparent 25%),
    linear-gradient(45deg,  transparent 75%, #c7c7cc 75%),
    linear-gradient(-45deg, transparent 75%, #c7c7cc 75%);
  background-size: 8px 8px;
  background-position: 0 0, 0 4px, 4px -4px, -4px 0px;
}

/* ── Furniture List (multi mode) ─────────────────────────────── */
.furniture-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.furniture-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #f9f9fb;
  border: 1px solid #e5e5ea;
  border-radius: 12px;
  padding: 8px;
}

.furniture-thumb {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
}

.furniture-name {
  font-size: 12px;
  color: #3c3c43;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.furniture-remove {
  width: 24px;
  height: 24px;
  background: transparent;
  border: none;
  cursor: pointer;
  color: #86868b;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: all .15s;
  flex-shrink: 0;
}

.furniture-remove:hover {
  background: rgba(255,59,48,0.1);
  color: #ff3b30;
}

.add-more {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border: 1.5px dashed #d1d1d6;
  border-radius: 12px;
  cursor: pointer;
  color: #86868b;
  font-size: 12px;
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
  transition: all .2s;
  background: transparent;
  position: relative;
  overflow: hidden;
  width: 100%;
}

.add-more:hover { border-color: #0071e3; color: #0071e3; }

.add-more input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.count-badge {
  background: #f2f2f7;
  border: 1px solid #e5e5ea;
  color: #86868b;
  font-size: 10px;
  font-family: 'SF Mono', ui-monospace, monospace;
  padding: 2px 7px;
  border-radius: 20px;
  margin-left: auto;
}

/* ── Tips ────────────────────────────────────────────────────── */
.tips-block { padding-top: 16px; margin-top: auto; }

.tips-text {
  font-size: 11px;
  color: #aeaeb2;
  line-height: 2;
}

/* ── Canvas Placeholder ──────────────────────────────────────── */
.canvas-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  color: #aeaeb2;
}

.canvas-placeholder svg {
  width: 60px;
  height: 60px;
  stroke: #d1d1d6;
  margin-bottom: 16px;
}

.canvas-placeholder h3 {
  font-size: 18px;
  font-weight: 500;
  color: #aeaeb2;
  margin-bottom: 8px;
}

.canvas-placeholder p {
  font-size: 13px;
  color: #c7c7cc;
  line-height: 1.6;
  max-width: 280px;
}

/* ── Canvas Image Wrap ───────────────────────────────────────── */
.canvas-img-wrap {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.canvas-img {
  max-width: 100%;
  max-height: 100%;
  display: block;
  object-fit: contain;
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.1);
}

/* ── Loading Overlay ─────────────────────────────────────────── */
.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.loading-ring {
  width: 44px;
  height: 44px;
  border: 2px solid #e5e5ea;
  border-top-color: #0071e3;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-text {
  font-size: 14px;
  font-weight: 500;
  color: #3c3c43;
}

.loading-steps {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
  align-self: stretch;
  padding: 0 32px;
}

.loading-step {
  font-size: 12px;
  color: #aeaeb2;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  transition: color .3s;
}

.loading-step.done   { color: #34c759; }
.loading-step.active { color: #0071e3; }

.step-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

/* ── Result Badge ────────────────────────────────────────────── */
.result-badge {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(52,199,89,0.1);
  border: 1px solid rgba(52,199,89,0.28);
  color: #34c759;
  font-size: 11px;
  font-family: 'SF Mono', ui-monospace, monospace;
  padding: 5px 12px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.result-badge svg { width: 10px; height: 10px; }

/* ── Model Selector ──────────────────────────────────────────── */
.model-selector {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.model-option {
  background: #f9f9fb;
  border: 1.5px solid #e5e5ea;
  border-radius: 12px;
  padding: 10px 12px;
  cursor: pointer;
  text-align: left;
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
  color: #86868b;
  transition: all .2s;
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: relative;
}

.model-option:hover:not(.active):not(:disabled) {
  border-color: #c7c7cc;
  color: #3c3c43;
}

.model-option.active {
  border-color: #0071e3;
  background: rgba(0,113,227,0.05);
  color: #1d1d1f;
}

/* model-option 不再被 disabled，保持可点击 */

.model-option.active::after {
  content: '';
  position: absolute;
  top: 12px;
  right: 12px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #0071e3;
}

.model-name { font-size: 13px; font-weight: 500; color: inherit; }

.model-sub {
  font-size: 10px;
  font-family: 'SF Mono', ui-monospace, monospace;
  color: #aeaeb2;
}

/* ── Buttons ─────────────────────────────────────────────────── */
.action-panel {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.btn {
  width: 100%;
  padding: 11px;
  border-radius: 22px;
  border: none;
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: all .18s;
}

.btn-primary {
  background: #0071e3;
  color: #fff;
}

.btn-primary:hover:not(:disabled) { background: #0077ed; }
.btn-primary:disabled { opacity: 0.34; cursor: not-allowed; }

.btn-secondary {
  background: #f2f2f7;
  color: #3c3c43;
}

.btn-secondary:hover:not(:disabled) { background: #e5e5ea; }
.btn-secondary:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-success {
  background: rgba(52,199,89,0.1);
  border: 1px solid rgba(52,199,89,0.25);
  color: #34c759;
}

.btn-success:hover:not(:disabled) { background: rgba(52,199,89,0.16); }
.btn-success:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-ghost {
  background: transparent;
  border: 1px solid #e5e5ea;
  color: #aeaeb2;
}

.btn-ghost:hover:not(:disabled) {
  color: #ff3b30;
  border-color: rgba(255,59,48,0.28);
  background: rgba(255,59,48,0.05);
}

/* ── Status ──────────────────────────────────────────────────── */
.status-section {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.status-card {
  background: #f9f9fb;
  border: 1px solid #f2f2f7;
  border-radius: 12px;
  padding: 10px 12px;
}

.status-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #aeaeb2;
  margin-bottom: 3px;
}

.status-val {
  font-family: 'SF Mono', ui-monospace, monospace;
  font-size: 11px;
  color: #3c3c43;
}

.status-val.ok      { color: #34c759; }
.status-val.err     { color: #ff3b30; }
.status-val.loading { color: #0071e3; }

.divider {
  height: 1px;
  background: #f2f2f7;
  margin: 2px 0;
}

/* ── Statusbar dot ───────────────────────────────────────────── */
.statusbar-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #34c759;
  flex-shrink: 0;
}

.statusbar-dot.loading {
  background: #0071e3;
  animation: pulse 1.2s ease infinite;
}

.statusbar-dot.err { background: #ff3b30; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.28; }
}

/* ── Toggle Switch ───────────────────────────────────────────── */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.toggle-switch {
  position: relative;
  flex-shrink: 0;
  width: 44px;
  height: 26px;
  cursor: pointer;
}

.toggle-switch input { display: none; }

.toggle-track {
  position: absolute;
  inset: 0;
  border-radius: 13px;
  background: #e5e5ea;
  transition: background .22s;
}

.toggle-track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.18);
  transition: transform .22s;
}

.toggle-switch input:checked + .toggle-track { background: #34c759; }
.toggle-switch input:checked + .toggle-track::after { transform: translateX(18px); }

/* ── Toast ───────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 28px;
  right: 28px;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(0,0,0,0.08);
  box-shadow: 0 4px 24px rgba(0,0,0,0.12);
  color: #1d1d1f;
  padding: 13px 18px;
  border-radius: 14px;
  font-size: 13px;
  z-index: 1000;
  animation: fadeIn .2s ease;
  max-width: 320px;
  line-height: 1.5;
}

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