/* ==========================================================================
   Popupsnap Lucky Wheel Creator — lucky-wheel.css
   Mobile-first responsive stylesheet for interactive wheel tool
   RTL-first, dark theme, 375px base viewport
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Wheel Tool Layout (Mobile-First: stacked)
   -------------------------------------------------------------------------- */
.wheel-tool-container {
  max-width: 500px;
  margin: 0 auto;
  padding: 20px 0;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* Preview: wheel + spin button */
.wheel-preview-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  order: -1; /* Wheel on top on mobile */
}

.wheel-container {
  position: relative;
  width: 100%;
  max-width: 280px;
  margin: 0 auto;
}

.wheel-canvas-wrapper {
  width: 100%;
  aspect-ratio: 1 / 1;
  position: relative;
  border-radius: 50%;
  box-shadow:
    0 0 0 6px rgba(99, 102, 241, 0.2),
    0 0 0 10px rgba(99, 102, 241, 0.08),
    0 16px 32px rgba(0, 0, 0, 0.4);
  overflow: hidden;
}

.wheel-canvas {
  display: block;
  width: 100%;
  height: 100%;
  transition: transform 6s cubic-bezier(0.17, 0.67, 0.12, 0.99);
}

/* Wheel center hub */
.wheel-hub {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0B0F1A 0%, rgba(255,255,255,0.1) 100%);
  border: 2px solid rgba(99, 102, 241, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.wheel-hub::after {
  content: '';
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%);
}

/* Wheel pointer */
.wheel-pointer {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 14px solid transparent;
  border-right: 14px solid transparent;
  border-top: 24px solid #EF4444;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
  z-index: 20;
}

/* Spin button */
.wheel-spin-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  max-width: 280px;
  height: 48px;
  padding: 0 28px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%);
  color: #fff;
  font-family: 'Cairo', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 8px 24px rgba(99, 102, 241, 0.4);
}

.wheel-spin-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 32px rgba(99, 102, 241, 0.5);
}

.wheel-spin-btn:active { transform: translateY(0); }

.wheel-spin-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.wheel-spin-btn i { font-size: 18px; }

/* --------------------------------------------------------------------------
   2. Segment Editor
   -------------------------------------------------------------------------- */
.wheel-config-section {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 20px;
}

.wheel-section-title {
  font-family: 'Cairo', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 16px;
  text-align: center;
  color: rgba(255, 255, 255, 0.8);
}

.wheel-segments-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

/* Segment item — compact card */
.wheel-segment-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  transition: border-color 0.2s;
}

.wheel-segment-item:focus-within {
  border-color: rgba(99, 102, 241, 0.3);
}

/* Top row: name + color + remove */
.wheel-segment-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Prize name input */
.wheel-segment-input {
  flex: 1;
  min-width: 0;
  height: 40px;
  padding: 0 12px;
  border: none;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  color: #fff;
  font-family: 'Cairo', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  outline: none;
  transition: background 0.2s;
  direction: rtl;
}

.wheel-segment-input::placeholder { color: rgba(255, 255, 255, 0.35); }
.wheel-segment-input:focus { background: rgba(255, 255, 255, 0.12); }

/* Color picker — compact circle */
.wheel-segment-color {
  width: 36px;
  height: 36px;
  min-width: 36px;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  padding: 0;
  background: transparent;
}

.wheel-segment-color::-webkit-color-swatch-wrapper { padding: 2px; }
.wheel-segment-color::-webkit-color-swatch {
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-radius: 50%;
}
.wheel-segment-color::-moz-color-swatch {
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-radius: 50%;
}

/* Remove button — small */
.wheel-segment-remove {
  width: 36px;
  height: 36px;
  min-width: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  border-radius: 8px;
  color: rgba(239, 68, 68, 0.6);
  font-size: 18px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.wheel-segment-remove:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #EF4444;
}

.wheel-segment-remove:disabled {
  opacity: 0.2;
  cursor: not-allowed;
  color: rgba(255, 255, 255, 0.3);
}

/* Coupon code input — compact */
.wheel-segment-coupon {
  width: 100%;
  height: 32px;
  padding: 0 10px;
  border: none;
  background: rgba(16, 185, 129, 0.06);
  border-radius: 6px;
  color: #10B981;
  font-family: 'Inter', monospace;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.05em;
  outline: none;
  transition: background 0.2s;
  box-sizing: border-box;
  direction: ltr;
  text-align: left;
}

.wheel-segment-coupon::placeholder {
  color: rgba(255, 255, 255, 0.2);
  font-weight: 400;
  letter-spacing: 0;
}

.wheel-segment-coupon:focus {
  background: rgba(16, 185, 129, 0.1);
}

/* Add segment button */
.wheel-add-segment-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 40px;
  padding: 0 20px;
  border: 1px dashed rgba(99, 102, 241, 0.3);
  border-radius: 10px;
  background: transparent;
  color: rgba(99, 102, 241, 0.7);
  font-family: 'Cairo', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.wheel-add-segment-btn:hover {
  border-color: rgba(99, 102, 241, 0.5);
  background: rgba(99, 102, 241, 0.06);
  color: #6366F1;
}

.wheel-add-segment-btn i { font-size: 14px; }

/* Segment count hint */
.wheel-segments-hint {
  text-align: center;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.35);
  margin-top: 8px;
}

/* --------------------------------------------------------------------------
   3. Winner Modal
   -------------------------------------------------------------------------- */
.wheel-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(11, 15, 26, 0.95);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
}

.wheel-modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.wheel-modal {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  padding: 32px 24px;
  max-width: 400px;
  width: 100%;
  text-align: center;
  transform: scale(0.9);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.wheel-modal-overlay.active .wheel-modal { transform: scale(1); }

.wheel-winner-icon {
  width: 72px;
  height: 72px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: linear-gradient(135deg, #10B981 0%, #34D399 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  animation: winnerPulse 0.6s ease-out;
}

@keyframes winnerPulse {
  0% { transform: scale(0); }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

.wheel-modal-title {
  font-family: 'Cairo', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 22px;
  font-weight: 800;
  margin: 0 0 8px;
  color: #fff;
}

.wheel-modal-subtitle {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.6);
  margin: 0 0 20px;
}

.wheel-winner-prize {
  padding: 16px;
  background: rgba(99, 102, 241, 0.1);
  border: 2px solid rgba(99, 102, 241, 0.3);
  border-radius: 14px;
  margin-bottom: 20px;
}

.wheel-winner-prize-text {
  font-family: 'Cairo', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 20px;
  font-weight: 700;
  color: #6366F1;
  line-height: 1.5;
}

.wheel-coupon-section { margin-bottom: 20px; }

.wheel-coupon-label {
  display: block;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.6);
  margin-bottom: 8px;
}

.wheel-coupon-code {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  font-family: 'Inter', monospace;
  font-size: 18px;
  font-weight: 700;
  color: #10B981;
  letter-spacing: 0.05em;
}

.wheel-copy-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 44px;
  padding: 0 24px;
  border: none;
  border-radius: 12px;
  background: rgba(99, 102, 241, 0.15);
  color: #6366F1;
  font-family: 'Cairo', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.wheel-copy-btn:hover { background: rgba(99, 102, 241, 0.25); }
.wheel-copy-btn.copied { background: rgba(16, 185, 129, 0.2); color: #10B981; }

.wheel-close-modal-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 50%;
  color: rgba(255, 255, 255, 0.6);
  font-size: 18px;
  cursor: pointer;
  transition: all 0.2s;
  margin: 0 auto;
}

.wheel-close-modal-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

/* --------------------------------------------------------------------------
   4. Confetti Canvas
   -------------------------------------------------------------------------- */
.wheel-confetti-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10000;
}

/* --------------------------------------------------------------------------
   5. Embed Code Section (full-width, below columns)
   -------------------------------------------------------------------------- */
.wheel-embed-section {
  width: 100%;
  max-width: 700px;
  margin: 12px auto 0;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 20px;
  box-sizing: border-box;
}

.wheel-embed-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.5);
  margin-bottom: 10px;
  text-align: center;
}

.wheel-embed-code {
  width: 100%;
  max-height: 160px;
  overflow: auto;
  padding: 14px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  font-family: 'Inter', monospace;
  font-size: 12px;
  line-height: 1.6;
  color: #10B981;
  direction: ltr;
  text-align: left;
  white-space: pre-wrap;
  word-break: break-all;
  box-sizing: border-box;
  margin: 0;
}

.wheel-embed-copy-wrapper {
  display: flex;
  justify-content: center;
  margin-top: 12px;
}

.wheel-embed-copy-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 24px;
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: 999px;
  background: transparent;
  color: rgba(99, 102, 241, 0.8);
  font-family: 'Cairo', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.wheel-embed-copy-btn:hover {
  background: rgba(99, 102, 241, 0.08);
  border-color: #6366F1;
  color: #6366F1;
}

.wheel-embed-copy-btn.copied {
  background: rgba(16, 185, 129, 0.1);
  border-color: #10B981;
  color: #10B981;
}

/* --------------------------------------------------------------------------
   6. Desktop Layout (768px+)
   -------------------------------------------------------------------------- */
@media (min-width: 768px) {
  .wheel-tool-container {
    max-width: 960px;
    flex-direction: row;
    align-items: flex-start;
    gap: 32px;
  }

  /* Wheel on the right (RTL) — larger and prominent */
  .wheel-preview-section {
    flex: 1 1 0%;
    order: 0;
    position: sticky;
    top: 120px;
  }

  .wheel-container {
    max-width: 340px;
  }

  .wheel-spin-btn {
    max-width: 340px;
  }

  /* Config on the left (RTL) — compact sidebar */
  .wheel-config-section {
    flex: 0 0 360px;
    position: sticky;
    top: 120px;
  }

  /* Single-row segment layout on desktop */
  .wheel-segment-item {
    flex-direction: row;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
  }

  .wheel-segment-row {
    flex: 1;
    min-width: 0;
  }

  .wheel-segment-coupon {
    width: 110px;
    flex-shrink: 0;
    height: 36px;
  }

  .wheel-add-segment-btn { width: auto; }

  .wheel-embed-section {
    max-width: 960px;
  }

  .wheel-embed-code { color: #A78BFA; }
}

@media (min-width: 1024px) {
  .wheel-tool-container { max-width: 1060px; }

  .wheel-config-section { flex: 0 0 400px; }

  .wheel-container { max-width: 380px; }
  .wheel-spin-btn { max-width: 380px; }

  .wheel-embed-section { max-width: 1060px; }

  .wheel-modal {
    padding: 40px 32px;
    max-width: 480px;
  }
  .wheel-winner-prize-text { font-size: 24px; }
}

/* --------------------------------------------------------------------------
   7. Animations
   -------------------------------------------------------------------------- */
.wheel-canvas.spinning { /* Transform set via JS */ }

@keyframes modalFadeIn {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes copySuccess {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.wheel-copy-btn.copied,
.wheel-embed-copy-btn.copied {
  animation: copySuccess 0.3s ease;
}

/* --------------------------------------------------------------------------
   8. RTL & Accessibility
   -------------------------------------------------------------------------- */
[dir="rtl"] .wheel-segment-input { text-align: right; }
[dir="rtl"] .wheel-embed-code { direction: ltr; text-align: left; }

.wheel-spin-btn:focus-visible,
.wheel-segment-input:focus-visible,
.wheel-segment-coupon:focus-visible,
.wheel-segment-color:focus-visible,
.wheel-segment-remove:focus-visible,
.wheel-add-segment-btn:focus-visible,
.wheel-copy-btn:focus-visible,
.wheel-embed-copy-btn:focus-visible,
.wheel-close-modal-btn:focus-visible {
  outline: 2px solid #6366F1;
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .wheel-canvas { transition-duration: 3s; }
  .wheel-modal { transition: none; }
  .wheel-winner-icon { animation: none; }
}

/* --------------------------------------------------------------------------
   9. Utility Classes
   -------------------------------------------------------------------------- */
.wheel-hidden { display: none !important; }

.wheel-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
