/* Image Fitting Demo - App Styles */
#ifd-app {
  max-width: 960px;
  margin: 0 auto;
  padding: 20px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #333;
}

#ifd-app h2 {
  margin: 0 0 20px;
  font-size: 1.4em;
  color: #1a1a1a;
}

/* Steps */
.ifd-step {
  display: none;
}
.ifd-step.ifd-active {
  display: block;
}

/* Template Grid */
.ifd-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.ifd-template-card {
  border: 2px solid #ddd;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
  background: #fff;
}
.ifd-template-card:hover {
  border-color: #0073aa;
  box-shadow: 0 2px 8px rgba(0, 115, 170, 0.2);
}
.ifd-template-card img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  display: block;
}
.ifd-template-card .ifd-card-info {
  padding: 12px;
}
.ifd-template-card .ifd-card-info h3 {
  margin: 0 0 4px;
  font-size: 1em;
}
.ifd-template-card .ifd-card-info span {
  font-size: 0.85em;
  color: #666;
}

/* Info bar */
.ifd-info-bar {
  background: #f0f6fc;
  border: 1px solid #c8d7e8;
  border-radius: 6px;
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: 0.9em;
}

/* AI hint */
.ifd-ai-hint {
  display: block;
  margin-top: 6px;
  font-size: 0.82em;
  color: #7c5cfc;
  font-style: italic;
}

/* Dropzone */
.ifd-dropzone {
  border: 2px dashed #aaa;
  border-radius: 8px;
  padding: 40px 20px;
  text-align: center;
  transition: border-color 0.2s, background 0.2s;
  margin-bottom: 16px;
  position: relative;
}
.ifd-dropzone.ifd-dragover {
  border-color: #0073aa;
  background: #f0f6fc;
}
.ifd-dropzone-text {
  font-size: 1.1em;
  margin: 0 0 8px;
  color: #555;
}
.ifd-dropzone-or {
  margin: 8px 0;
  color: #999;
  font-size: 0.9em;
}
.ifd-dropzone-hint {
  margin: 12px 0 0;
  font-size: 0.8em;
  color: #999;
}

/* Fit mode selector */
.ifd-fit-mode {
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.ifd-fit-mode select {
  padding: 6px 10px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 0.9em;
}

/* Buttons */
.ifd-btn {
  display: inline-block;
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  font-size: 0.95em;
  cursor: pointer;
  transition: background 0.2s;
}
.ifd-btn-primary {
  background: #0073aa;
  color: #fff;
}
.ifd-btn-primary:hover {
  background: #005a87;
}
.ifd-btn-secondary {
  background: #e0e0e0;
  color: #333;
}
.ifd-btn-secondary:hover {
  background: #ccc;
}

/* Progress */
.ifd-progress {
  margin-top: 16px;
}
.ifd-progress-bar {
  height: 4px;
  background: #0073aa;
  border-radius: 2px;
  animation: ifd-pulse 1.5s ease-in-out infinite;
}
@keyframes ifd-pulse {
  0%, 100% { opacity: 0.4; width: 30%; }
  50% { opacity: 1; width: 80%; }
}
.ifd-progress-text {
  display: block;
  margin-top: 8px;
  font-size: 0.85em;
  color: #666;
}

/* Tabs */
.ifd-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 0;
  border-bottom: 2px solid #ddd;
}
.ifd-tab {
  padding: 10px 20px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  font-size: 0.95em;
  color: #666;
}
.ifd-tab.ifd-tab-active {
  border-bottom-color: #0073aa;
  color: #0073aa;
  font-weight: 600;
}

/* Tab panels */
.ifd-tab-panel {
  display: none;
  padding: 20px 0;
}
.ifd-tab-panel.ifd-tab-active {
  display: block;
}

/* Canvas */
#ifd-preview-canvas,
#ifd-distance-canvas {
  max-width: 100%;
  border: 1px solid #ddd;
  border-radius: 4px;
  display: block;
}

/* Distance controls */
.ifd-distance-controls {
  display: flex;
  gap: 24px;
  margin-top: 12px;
}
.ifd-distance-controls label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9em;
}

/* Actions */
.ifd-actions {
  display: flex;
  gap: 12px;
  margin-top: 20px;
}

/* Status */
.ifd-status {
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 0.9em;
}
.ifd-status.ifd-success {
  background: #edf7ed;
  color: #2e7d32;
  border: 1px solid #c8e6c9;
}
.ifd-status.ifd-loading {
  background: #f0f6fc;
  color: #0073aa;
  border: 1px solid #c8d7e8;
}

/* Error */
.ifd-error {
  background: #fdecea;
  color: #c62828;
  border: 1px solid #f5c6cb;
  border-radius: 6px;
  padding: 12px 16px;
  margin-top: 16px;
  font-size: 0.9em;
}

/* Loading */
.ifd-loading {
  text-align: center;
  padding: 40px;
  color: #999;
}

/* Responsive */
@media (max-width: 700px) {
  .ifd-grid {
    grid-template-columns: 1fr;
  }
  .ifd-distance-controls {
    flex-direction: column;
  }
}
