/* ========== Lucky Wheel Tool Page ========== */

.tool-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

.tool-header {
  text-align: center;
  margin-bottom: 24px;
}

.tool-header h1 {
  font-size: 32px;
  font-weight: 800;
  color: var(--color-heading);
  margin-bottom: 8px;
}

.tool-header .tool-desc {
  font-size: 16px;
  color: var(--color-muted);
  max-width: 700px;
  margin: 0 auto;
  line-height: 1.6;
}

#statusMessage {
  text-align: center;
  margin-bottom: 12px;
  min-height: 28px;
  font-size: 14px;
  font-weight: 600;
}

.status-success { color: #10b981; }
.status-error { color: #ef4444; }

/* Layout */
.wheel-layout {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 24px;
  margin-bottom: 24px;
}

/* Wheel Area */
.wheel-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.wheel-canvas-wrap {
  position: relative;
  width: 360px;
  height: 360px;
}

#wheelCanvas {
  width: 360px;
  height: 360px;
  border-radius: 50%;
  box-shadow: 0 4px 24px rgba(0,0,0,0.15);
}

.wheel-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

/* Theme selector */
.theme-selector {
  display: flex;
  gap: 8px;
  align-items: center;
}

.theme-selector label {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-muted);
}

.theme-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
}

.theme-btn.active {
  border-color: var(--color-primary);
  transform: scale(1.15);
}

.theme-btn-red { background: linear-gradient(135deg, #e74c3c, #f39c12); }
.theme-btn-blue { background: linear-gradient(135deg, #3498db, #2ecc71); }
.theme-btn-rainbow { background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red); }

/* Side Panel */
.side-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel-card {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  overflow: hidden;
}

.panel-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg);
  font-size: 13px;
  font-weight: 700;
  color: var(--color-heading);
}

.panel-card-body {
  padding: 12px 14px;
}

/* Prize Editor */
.prize-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 260px;
  overflow-y: auto;
}

.prize-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 13px;
}

.prize-item .prize-color {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  border: 1px solid var(--color-border);
  cursor: pointer;
  flex-shrink: 0;
}

.prize-item .prize-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
  color: var(--color-text);
}

.prize-item .prize-weight {
  width: 44px;
  padding: 2px 4px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  font-size: 11px;
  text-align: center;
}

.prize-item .prize-del-btn {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: #ef4444;
  cursor: pointer;
  border-radius: 4px;
  font-size: 14px;
  flex-shrink: 0;
}

.prize-item .prize-del-btn:hover {
  background: #fef2f2;
}

.prize-add-row {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.prize-add-row input[type="text"] {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 13px;
  outline: none;
}

.prize-add-row input[type="text"]:focus {
  border-color: var(--color-primary);
}

/* Settings */
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 13px;
  color: var(--color-text);
}

.setting-row label {
  font-weight: 500;
}

.setting-row input[type="range"] {
  width: 120px;
}

.setting-row .setting-value {
  min-width: 28px;
  text-align: center;
  font-weight: 700;
  color: var(--color-primary);
  font-size: 14px;
}

/* Result Dialog */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0,0,0,0.5);
  align-items: center;
  justify-content: center;
}

.modal-overlay.show {
  display: flex;
}

.result-modal {
  background: #fff;
  border-radius: 16px;
  padding: 40px 36px 32px;
  max-width: 400px;
  width: 90%;
  text-align: center;
  animation: modalBounce 0.35s ease-out;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

@keyframes modalBounce {
  0% { transform: scale(0.5); opacity: 0; }
  60% { transform: scale(1.08); }
  100% { transform: scale(1); opacity: 1; }
}

.result-modal .result-icon {
  font-size: 64px;
  margin-bottom: 8px;
}

.result-modal .result-label {
  font-size: 14px;
  color: #6b7280;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 2px;
}

.result-modal .result-name {
  font-size: 28px;
  font-weight: 800;
  color: #1e293b;
  margin-bottom: 20px;
  padding: 8px 24px;
  display: inline-block;
  border-radius: 8px;
}

.result-modal .result-close-btn {
  padding: 10px 36px;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  background: var(--color-primary);
  color: #fff;
  transition: opacity 0.2s;
}

.result-modal .result-close-btn:hover {
  opacity: 0.9;
}

/* History & Stats */
.history-list {
  max-height: 120px;
  overflow-y: auto;
  font-size: 12px;
}

.history-item {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
  border-bottom: 1px solid var(--color-border);
  color: var(--color-muted);
}

.history-item:last-child {
  border-bottom: none;
}

.stats-panel {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-bar-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

.stat-bar-label {
  min-width: 60px;
  text-align: right;
  font-weight: 500;
  color: var(--color-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stat-bar-track {
  flex: 1;
  height: 12px;
  background: var(--color-bg);
  border-radius: 6px;
  overflow: hidden;
}

.stat-bar-fill {
  height: 100%;
  border-radius: 6px;
  transition: width 0.4s ease;
}

.stat-bar-count {
  min-width: 32px;
  text-align: center;
  font-weight: 600;
  color: var(--color-muted);
  font-size: 11px;
}

/* Buttons */
.tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.tool-btn-primary {
  background: var(--color-primary);
  color: #fff;
}

.tool-btn-primary:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.tool-btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.tool-btn-secondary {
  background: #10b981;
  color: #fff;
}

.tool-btn-secondary:hover {
  background: #059669;
}

.tool-btn-outline {
  background: transparent;
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.tool-btn-outline:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.tool-btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

.tool-btn-danger {
  background: #ef4444;
  color: #fff;
}

.tool-btn-danger:hover {
  background: #dc2626;
}

/* Tool Info */
.tool-info {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 20px 24px;
  margin-top: 24px;
}

.tool-info h3 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 10px;
  color: var(--color-heading);
}

.tool-info ul {
  padding-left: 20px;
  margin-bottom: 10px;
}

.tool-info li {
  font-size: 14px;
  color: var(--color-muted);
  line-height: 1.7;
}

.info-tip {
  font-size: 13px;
  color: #10b981;
  font-weight: 600;
  margin-top: 8px;
}

/* Responsive */
@media (max-width: 900px) {
  .wheel-layout {
    grid-template-columns: 1fr;
  }
  .wheel-canvas-wrap {
    width: 280px;
    height: 280px;
  }
  #wheelCanvas {
    width: 280px;
    height: 280px;
  }
  .side-panel {
    max-width: 500px;
    margin: 0 auto;
  }
}

@media (max-width: 600px) {
  .tool-container {
    padding: 16px;
  }
  .tool-header h1 {
    font-size: 24px;
  }
  .wheel-canvas-wrap {
    width: 240px;
    height: 240px;
  }
  #wheelCanvas {
    width: 240px;
    height: 240px;
  }
  .result-modal {
    padding: 28px 20px 24px;
  }
  .result-modal .result-name {
    font-size: 22px;
  }
  .prize-item {
    font-size: 12px;
  }
}

/* RTL overrides for Arabic */
html[dir="rtl"] .tool-info ul {
  padding-left: 0;
  padding-right: 20px;
}

html[dir="rtl"] .result-modal .result-label {
  text-transform: none;
  letter-spacing: 0;
}