/* ============================================================
   SizeFinder Widget — Styles
   ============================================================ */

/* Overlay */
.sf-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(0,0,0,0.5); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  opacity: 0; transition: opacity 0.25s ease;
}
.sf-overlay.sf-visible { opacity: 1; }

/* Modal */
.sf-modal {
  background: #fff; border-radius: 16px; width: 100%; max-width: 520px;
  max-height: 90vh; overflow-y: auto; position: relative;
  box-shadow: 0 24px 64px rgba(0,0,0,0.2);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: #1a1a1a;
  transform: translateY(20px); transition: transform 0.3s ease;
}
.sf-overlay.sf-visible .sf-modal { transform: translateY(0); }

/* Header */
.sf-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 24px 28px 0;
}
.sf-title { font-size: 20px; font-weight: 700; margin: 0; }

.sf-close {
  background: none; border: none; font-size: 28px; cursor: pointer;
  color: #999; padding: 0; line-height: 1; width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; transition: all 0.2s;
}
.sf-close:hover { background: #f0f0f0; color: #333; }

/* Step Indicator */
.sf-steps {
  display: flex; align-items: center; justify-content: center;
  padding: 20px 28px 8px; gap: 8px;
}
.sf-step {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
  background: #f0f0f0; color: #aaa; transition: all 0.3s;
}
.sf-step.active { background: #1a1a1a; color: #fff; }
.sf-step.done { background: #22c55e; color: #fff; }
.sf-step-line { width: 48px; height: 2px; background: #e5e5e5; border-radius: 1px; }

/* Content */
.sf-content { padding: 8px 28px 28px; }
.sf-subtitle { color: #666; font-size: 14px; margin: 0 0 24px; line-height: 1.5; }

/* Mode Cards */
.sf-mode-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.sf-mode-card {
  display: flex; flex-direction: column; align-items: center;
  padding: 24px 16px; border: 2px solid #e8e8e8; border-radius: 14px;
  background: #fff; cursor: pointer; transition: all 0.2s;
  text-align: center; gap: 10px;
}
.sf-mode-card:hover { border-color: #1a1a1a; transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.08); }
.sf-mode-card strong { font-size: 16px; }
.sf-mode-card span { font-size: 12px; color: #888; line-height: 1.5; }
.sf-mode-icon { font-size: 36px; }

/* Fields */
.sf-field { margin-bottom: 24px; }
.sf-field label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 10px; color: #333; }

.sf-field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

.sf-input-wrap { display: flex; align-items: center; gap: 8px; }
.sf-input {
  width: 100%; padding: 12px 14px; border: 2px solid #e8e8e8; border-radius: 10px;
  font-size: 16px; transition: border-color 0.2s; outline: none;
  font-family: inherit;
}
.sf-input:focus { border-color: #1a1a1a; }
.sf-unit { font-size: 14px; color: #aaa; font-weight: 600; min-width: 28px; }

/* Slider */
.sf-input-group { display: flex; align-items: center; gap: 16px; }

.sf-slider {
  -webkit-appearance: none; appearance: none;
  flex: 1; height: 6px; border-radius: 3px;
  background: #e5e5e5; outline: none;
}
.sf-slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 24px; height: 24px; border-radius: 50%;
  background: #1a1a1a; cursor: pointer; border: 3px solid #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}
.sf-slider::-moz-range-thumb {
  width: 24px; height: 24px; border-radius: 50%;
  background: #1a1a1a; cursor: pointer; border: 3px solid #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}
.sf-range-value {
  font-weight: 700; font-size: 18px; min-width: 80px; text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Body Types */
.sf-body-types { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }

.sf-body-type {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 14px 8px; border: 2px solid #e8e8e8; border-radius: 12px;
  background: #fff; cursor: pointer; transition: all 0.2s;
  font-size: 12px; font-weight: 500; color: #666;
  font-family: inherit; border-color: #e8e8e8;
}
.sf-body-type:hover { border-color: #bbb; }
.sf-body-type.active {
  border-color: #1a1a1a; background: #f5f5f5; color: #1a1a1a; font-weight: 700;
}

/* Body Silhouettes (SVG-like with CSS) */
.sf-silhouette {
  width: 28px; height: 52px; position: relative; display: flex; align-items: flex-end; justify-content: center;
}
.sf-silhouette-body {
  border-radius: 8px 8px 4px 4px; background: #ccc; transition: all 0.2s;
}
.sf-body-type.active .sf-silhouette-body { background: #1a1a1a; }
.sf-silhouette-head {
  width: 12px; height: 12px; border-radius: 50%; background: #ccc;
  position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  transition: all 0.2s;
}
.sf-body-type.active .sf-silhouette-head { background: #1a1a1a; }

.sf-body-type[data-value="slim"] .sf-silhouette-body { width: 14px; height: 34px; }
.sf-body-type[data-value="normal"] .sf-silhouette-body { width: 20px; height: 34px; }
.sf-body-type[data-value="athletic"] .sf-silhouette-body { width: 24px; height: 34px; border-radius: 6px 6px 4px 4px; }
.sf-body-type[data-value="heavy"] .sf-silhouette-body { width: 28px; height: 34px; }

/* Buttons */
.sf-nav { display: flex; gap: 12px; margin-top: 28px; }

.sf-btn {
  padding: 14px 28px; border-radius: 10px; font-weight: 600;
  font-size: 14px; cursor: pointer; transition: all 0.2s;
  border: 2px solid transparent; font-family: inherit;
  letter-spacing: 0.02em;
}
.sf-btn-primary {
  background: #1a1a1a; color: #fff; border-color: #1a1a1a; flex: 1;
}
.sf-btn-primary:hover { background: #333; }
.sf-btn-primary:active { transform: scale(0.98); }
.sf-btn-secondary {
  background: #fff; color: #1a1a1a; border-color: #e5e5e5;
}
.sf-btn-secondary:hover { border-color: #1a1a1a; }
.sf-button-group { display: flex; flex-direction: column; gap: 12px; margin: 24px 0; }

.sf-link {
  background: none; border: none; color: #aaa; cursor: pointer;
  font-size: 12px; text-decoration: underline; margin-top: 16px; font-family: inherit;
}
.sf-link:hover { color: #666; }

/* Result */
.sf-result-card {
  text-align: center; padding: 28px; background: #f8f8f8;
  border-radius: 16px; margin-bottom: 20px;
}
.sf-result-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 88px; height: 88px; border-radius: 50%;
  background: #1a1a1a; color: #fff; font-size: 32px; font-weight: 800;
  margin-bottom: 12px; box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}
.sf-result-label { font-size: 14px; color: #888; margin-bottom: 20px; }

.sf-confidence-bar {
  width: 100%; height: 8px; background: #e5e5e5; border-radius: 4px; overflow: hidden;
}
.sf-confidence-fill {
  height: 100%; border-radius: 4px; transition: width 0.8s cubic-bezier(0.4,0,0.2,1);
}
.sf-confidence-label {
  font-size: 13px; color: #888; margin-top: 10px; font-weight: 600;
}

.sf-reasoning {
  font-size: 14px; color: #444; line-height: 1.7; margin-bottom: 20px;
  padding: 16px; background: #f8f8f8; border-radius: 12px;
  border-left: 4px solid #1a1a1a;
}

.sf-alternatives { font-size: 14px; color: #666; margin-bottom: 20px; }
.sf-result-actions { display: flex; gap: 12px; }

/* Save Prompt */
.sf-divider { border: none; border-top: 1px solid #eee; margin: 24px 0; }
.sf-save-form { display: flex; flex-direction: column; gap: 14px; margin-top: 14px; }

.sf-checkbox {
  display: flex; align-items: flex-start; gap: 10px;
  font-size: 13px; cursor: pointer; color: #666; line-height: 1.4;
}
.sf-checkbox input { margin-top: 3px; accent-color: #1a1a1a; }

.sf-small { font-size: 13px; color: #666; }
.sf-muted { color: #aaa; }

/* Size Chart Table */
.sf-chart-scroll { overflow-x: auto; margin-bottom: 20px; -webkit-overflow-scrolling: touch; }

.sf-chart-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.sf-chart-table th,
.sf-chart-table td {
  padding: 12px 14px; text-align: center; border-bottom: 1px solid #eee;
}
.sf-chart-table th {
  background: #f5f5f5; font-weight: 700; position: sticky; top: 0;
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: #888;
}
.sf-chart-table tr.sf-highlight { background: #f0fdf4; font-weight: 600; }

/* Welcome */
.sf-welcome-icon { font-size: 48px; text-align: center; margin-bottom: 12px; }

/* Loading */
.sf-spinner {
  width: 44px; height: 44px; border: 3px solid #eee;
  border-top-color: #1a1a1a; border-radius: 50%;
  animation: sf-spin 0.7s linear infinite;
  margin: 48px auto;
}
@keyframes sf-spin { to { transform: rotate(360deg); } }

/* Error */
.sf-error-text { color: #dc2626; font-weight: 600; }

/* Saved notification */
.sf-toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #1a1a1a; color: #fff; padding: 12px 24px; border-radius: 10px;
  font-size: 14px; font-weight: 600; z-index: 10000;
  animation: sf-toast-in 0.3s ease, sf-toast-out 0.3s ease 2.5s forwards;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}
@keyframes sf-toast-in { from { transform: translateX(-50%) translateY(20px); opacity: 0; } }
@keyframes sf-toast-out { to { transform: translateX(-50%) translateY(20px); opacity: 0; } }

/* Trigger Button */
.sizefinder-trigger {
  display: inline-flex; align-items: center;
  padding: 12px 24px; font-size: 14px; font-weight: 600;
  color: #1a1a1a; background: transparent;
  border: 2px solid #1a1a1a; border-radius: 8px;
  cursor: pointer; transition: all 0.2s; font-family: inherit;
  letter-spacing: 0.02em; text-transform: uppercase;
  gap: 8px;
}
.sizefinder-trigger:hover { background: #1a1a1a; color: #fff; }
.sizefinder-trigger svg { transition: stroke 0.2s; }
.sizefinder-trigger:hover svg { stroke: #fff; }

/* Responsive */
@media (max-width: 560px) {
  .sf-modal {
    border-radius: 20px 20px 0 0; max-height: 95vh;
    align-self: flex-end; margin: 0;
  }
  .sf-header { padding: 20px 20px 0; }
  .sf-content { padding: 8px 20px 20px; }
  .sf-mode-cards { grid-template-columns: 1fr; }
  .sf-field-grid { grid-template-columns: 1fr; }
  .sf-body-types { grid-template-columns: repeat(2, 1fr); }
  .sf-result-actions { flex-direction: column; }
}
