/**
 * Control Panels, Buttons, Knobs, & Interactive Elements
 * Styles the glassmorphism UI cards, drawing tools, sliders, knobs, and animations.
 */

/* ==========================================================================
   Control Panel (Left Side Glassmorphism Cards)
   ========================================================================== */
.controls-panel {
  background: var(--panel-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.1);
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.group-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.group-label {
  font-family: var(--font-heading);
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
}

/* Buttons and Tools */
.tools-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.btn {
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-main);
  background: var(--btn-bg);
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 0.6rem 0.75rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  transition: all 0.2s ease;
  user-select: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.btn:hover {
  background: var(--btn-hover);
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(1px);
}

.tool-btn.active {
  background: var(--btn-active-bg);
  color: var(--btn-active-text);
  box-shadow: 0 0 15px rgba(255, 204, 0, 0.4);
  font-weight: 700;
}

.btn-icon {
  font-size: 1.1rem;
}

/* Brush Settings */
.brush-settings {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  background: rgba(0, 0, 0, 0.2);
  padding: 0.75rem;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.color-picker-wrapper, .interaction-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.sub-label {
  font-size: 0.85rem;
  color: #fff;
  font-weight: 500;
}

input[type="color"] {
  -webkit-appearance: none;
  border: none;
  width: 36px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  background: transparent;
}

input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

input[type="color"]::-webkit-color-swatch {
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-radius: 6px;
}

.color-hex {
  font-family: monospace;
  font-size: 0.8rem;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.05);
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
}

.toggle-btn {
  padding: 0.4rem 0.75rem;
  font-size: 0.8rem;
  background: rgba(255, 255, 255, 0.12);
}

.toggle-btn.active-drag {
  background: #3b82f6;
  color: #fff;
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.4);
}

.toggle-btn.theme-neon {
  background: #a855f7;
  color: #fff;
  box-shadow: 0 0 10px rgba(168, 85, 247, 0.4);
}

/* Grid Size Controls */
.grid-size-display {
  font-family: var(--font-heading);
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-gold);
  background: rgba(0, 0, 0, 0.4);
  padding: 0.2rem 0.6rem;
  border-radius: 6px;
}

.slider {
  -webkit-appearance: none;
  width: 100%;
  height: 8px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.4);
  outline: none;
  margin: 0.5rem 0;
  touch-action: manipulation;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--text-gold);
  cursor: pointer;
  box-shadow: 0 0 8px rgba(255, 215, 0, 0.6);
  transition: transform 0.15s ease;
}

.slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.quick-size-buttons {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.4rem;
}

.size-btn {
  padding: 0.4rem 0.2rem;
  font-size: 0.75rem;
}

.size-btn.active {
  background: rgba(255, 255, 255, 0.25);
  border-color: rgba(255, 255, 255, 0.4);
}

/* Save Button */
.save-btn {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
  width: 100%;
  padding: 0.75rem;
  font-size: 1rem;
  font-weight: 700;
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}

.save-btn:hover {
  background: linear-gradient(135deg, #34d399 0%, #10b981 100%);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.5);
}

.save-btn.saved-feedback {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  box-shadow: 0 4px 15px rgba(59, 130, 246, 0.4);
}

/* Clear Button */
.clear-btn {
  background: linear-gradient(135deg, #ff416c 0%, #ff4b2b 100%);
  color: white;
  width: 100%;
  padding: 0.75rem;
  font-size: 1rem;
  font-weight: 700;
  box-shadow: 0 4px 15px rgba(255, 65, 108, 0.3);
}

.clear-btn:hover {
  background: linear-gradient(135deg, #ff537b 0%, #ff5e41 100%);
  box-shadow: 0 6px 20px rgba(255, 65, 108, 0.5);
}

/* ==========================================================================
   Bottom Knobs
   ========================================================================== */
.knobs-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 2rem;
  margin-top: 0.5rem;
}

.knob-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.knob {
  width: 88px;
  height: 88px;
  background: 
    repeating-radial-gradient(circle at center, transparent 0, transparent 4px, rgba(0,0,0,0.02) 4px, rgba(0,0,0,0.02) 6px),
    radial-gradient(circle at 30% 30%, #ffffff 0%, #f1f5f9 25%, #cbd5e1 70%, #94a3b8 100%);
  border: 5px solid #cbd5e1;
  border-radius: 50%;
  box-shadow: 
    var(--knob-shadow), 
    inset 0 3px 6px rgba(255, 255, 255, 0.9), 
    inset 0 -3px 6px rgba(0, 0, 0, 0.15);
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: grab;
  transition: transform 0.1s ease-out, box-shadow 0.2s ease, border-color 0.2s ease;
  position: relative;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.knob.dragging {
  cursor: grabbing;
  transform: scale(0.98);
  border-color: var(--text-gold);
  box-shadow: 0 0 20px rgba(255, 215, 0, 0.5), 0 8px 20px rgba(0, 0, 0, 0.6), inset 0 1px 3px rgba(255, 255, 255, 0.8);
}

.screen.neon-midnight ~ .knobs-container .knob.dragging,
.screen.neon-midnight .knob.dragging {
  border-color: #00f0ff;
  box-shadow: 0 0 25px rgba(0, 240, 255, 0.6), 0 8px 20px rgba(0, 0, 0, 0.6), inset 0 1px 3px rgba(255, 255, 255, 0.8);
}

.knob:hover {
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.7), inset 0 2px 4px rgba(255, 255, 255, 1);
}

.knob:active {
  transform: scale(0.96);
}

.knob-line {
  width: 5px;
  height: 34px;
  background: #94a3b8;
  border-radius: 2.5px;
  position: absolute;
  top: 10px;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.3);
}

.knob-label {
  font-family: var(--font-heading);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 2px;
  color: rgba(255, 255, 255, 0.8);
}

/* ==========================================================================
   Animations & Shake Effect
   ========================================================================== */
@keyframes shakeCasing {
  0% { transform: translate(1px, 1px) rotate(0deg); }
  10% { transform: translate(-3px, -2px) rotate(-1deg); }
  20% { transform: translate(-3px, 0px) rotate(1deg); }
  30% { transform: translate(3px, 2px) rotate(0deg); }
  40% { transform: translate(1px, -1px) rotate(1deg); }
  50% { transform: translate(-1px, 2px) rotate(-1deg); }
  60% { transform: translate(-3px, 1px) rotate(0deg); }
  70% { transform: translate(3px, 1px) rotate(-1deg); }
  80% { transform: translate(-1px, -1px) rotate(1deg); }
  90% { transform: translate(1px, 2px) rotate(0deg); }
  100% { transform: translate(0, 0) rotate(0deg); }
}

.shake-animation {
  animation: shakeCasing 0.6s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}
