/* Magic Bento Customizer Styles */

/* Container for side-by-side layout */
.bento-with-customizer {
  display: flex;
  gap: 20px;
  margin-bottom: 40px;
  align-items: stretch;
}

.bento-customizer-wrapper {
  flex: 0 0 320px;
  max-width: 320px;
  display: flex;
  flex-direction: column;
}

.bento-cards-wrapper {
  flex: 1;
  min-width: 0;
}

.bento-customizer-panel {
  background: #060010;
  border-radius: 15px;
  padding: 20px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
  border: 1px solid #392e4e;
  height: 100%;
  position: sticky;
  top: 100px;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 120px);
}

.customizer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-shrink: 0;
}

.customizer-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(132, 0, 255, 0.5) transparent;
  padding-right: 5px;
}

.customizer-content::-webkit-scrollbar {
  width: 6px;
}

.customizer-content::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 3px;
}

.customizer-content::-webkit-scrollbar-thumb {
  background: rgba(132, 0, 255, 0.5);
  border-radius: 3px;
}

.customizer-content::-webkit-scrollbar-thumb:hover {
  background: rgba(132, 0, 255, 0.7);
}

.customizer-header h3 {
  font-size: 1.2rem;
  font-weight: 600;
  background: linear-gradient(135deg, #b8b8b8 0%, #8a8a8a 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin: 0;
}

.customizer-toggle {
  background: rgba(132, 0, 255, 0.2);
  border: 1px solid rgba(132, 0, 255, 0.5);
  border-radius: 50%;
  width: 35px;
  height: 35px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  color: #8400ff;
}

.customizer-toggle:hover {
  background: rgba(132, 0, 255, 0.3);
  transform: scale(1.1);
}

.customizer-toggle i {
  font-size: 1.2rem;
}

.customizer-content {
  display: block;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Control Styles */
.customizer-control {
  margin-bottom: 20px;
}

.control-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 0.85rem;
  color: #e0e0e0;
  font-weight: 500;
}

.control-value {
  color: #8400ff;
  font-weight: 600;
  font-size: 0.9rem;
  background: rgba(132, 0, 255, 0.1);
  padding: 4px 12px;
  border-radius: 20px;
}

/* Slider Styles */
.control-slider {
  width: 100%;
  height: 6px;
  border-radius: 10px;
  background: linear-gradient(90deg, #2a2a2a 0%, #8400ff 100%);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.control-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: linear-gradient(135deg, #cbc3d3 0%, #837d81 100%);
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(132, 0, 255, 0.5);
  transition: all 0.2s ease;
}

.control-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  box-shadow: 0 6px 20px rgba(132, 0, 255, 0.7);
}

.control-slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: linear-gradient(135deg, #cbc3d3 0%, #837d81 100%);
  cursor: pointer;
  border: none;
  box-shadow: 0 4px 15px rgba(132, 0, 255, 0.5);
  transition: all 0.2s ease;
}

.control-slider::-moz-range-thumb:hover {
  transform: scale(1.2);
  box-shadow: 0 6px 20px rgba(132, 0, 255, 0.7);
}

/* Switches Container */
.customizer-switches {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.switch-control {
  background: rgba(0, 0, 0, 0.3);
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(132, 0, 255, 0.2);
  transition: all 0.3s ease;
}

.switch-control:hover {
  border-color: rgba(132, 0, 255, 0.5);
  background: rgba(0, 0, 0, 0.4);
}

.switch-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  user-select: none;
}

.switch-label span {
  color: #e0e0e0;
  font-size: 0.8rem;
  font-weight: 500;
}

/* Toggle Switch */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #2a2a2a;
  border: 1px solid #404040;
  transition: all 0.3s ease;
  border-radius: 34px;
}

.switch-slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 4px;
  bottom: 3px;
  background: linear-gradient(135deg, #666 0%, #888 100%);
  transition: all 0.3s ease;
  border-radius: 50%;
}

.switch input:checked + .switch-slider {
  background: linear-gradient(135deg, #cbc3d3 0%,  #837d81 100%);
  border-color: #8400ff;
}

.switch input:checked + .switch-slider:before {
  transform: translateX(20px);
  background: white;
  box-shadow: 0 2px 10px rgba(132, 0, 255, 0.5);
}

/* Color Presets */
.color-presets {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-top: 10px;
  flex-wrap: wrap;
}

/* Magnifier Toggle Button */
.magnifier-toggle {
  width: 35px;
  height: 35px;
  border-radius: 50%;
  border: none;
  background: radial-gradient(circle at 30% 30%, rgba(132, 0, 255, 0.9), rgba(132, 0, 255, 0.6));
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  overflow: visible;
}

.magnifier-toggle::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.8);
  background: transparent;
  transition: all 0.3s ease;
  z-index: 2;
}

/* Progress ring for long press */
.magnifier-progress-ring {
  position: absolute;
  top: -4px;
  left: -4px;
  right: -4px;
  bottom: -4px;
  border-radius: 50%;
  border: 3px solid transparent;
  border-top-color: rgba(255, 255, 255, 0.95);
  border-right-color: rgba(255, 255, 255, 0.7);
  z-index: 1;
  opacity: 0;
  transition: opacity 0.2s ease;
  filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.5));
}

.magnifier-toggle.pressing .magnifier-progress-ring {
  opacity: 1;
}

@keyframes fillProgress {
  0% {
    transform: rotate(0deg);
    border-top-color: rgba(255, 255, 255, 0.95);
    border-right-color: rgba(255, 255, 255, 0.7);
  }
  25% {
    border-top-color: rgba(132, 0, 255, 0.95);
    border-right-color: rgba(132, 0, 255, 0.7);
  }
  50% {
    border-top-color: rgba(255, 0, 170, 0.95);
    border-right-color: rgba(255, 0, 170, 0.7);
  }
  75% {
    border-top-color: rgba(132, 0, 255, 0.95);
    border-right-color: rgba(132, 0, 255, 0.7);
  }
  100% {
    transform: rotate(1080deg); /* 3 full rotations */
    border-top-color: rgba(255, 255, 255, 0.95);
    border-right-color: rgba(255, 255, 255, 0.7);
  }
}

/* Pressing state */
.magnifier-toggle.pressing {
  transform: scale(1.1);
  box-shadow: 
    0 0 20px rgba(132, 0, 255, 0.8),
    0 0 40px rgba(255, 0, 170, 0.4);
}

/* Feedback text for long press */
.magnifier-feedback-text {
  position: absolute;
  top: -45px;
  left: 50%;
  transform: translateX(-50%) translateY(-10px);
  background: linear-gradient(135deg, rgba(132, 0, 255, 0.98), rgba(255, 0, 170, 0.98));
  color: white;
  padding: 8px 15px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  opacity: 0;
  transition: all 0.3s ease;
  pointer-events: none;
  z-index: 1000;
  box-shadow: 
    0 4px 15px rgba(0, 0, 0, 0.3),
    0 0 20px rgba(132, 0, 255, 0.3);
  backdrop-filter: blur(5px);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.magnifier-feedback-text::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-top: 7px solid rgba(132, 0, 255, 0.98);
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.2));
}

.magnifier-toggle:hover {
  transform: scale(1.15);
  border-color: #8400ff;
  box-shadow: 0 5px 18px rgba(132, 0, 255, 0.3);
}

.magnifier-toggle:hover::before {
  background: rgba(132, 0, 255, 0.8);
}

.magnifier-toggle.active {
  background: radial-gradient(circle, rgba(132, 0, 255, 0.6) 0%, rgba(255, 0, 170, 0.3) 70%);
  border-color: white;
  transform: scale(1.15);
  box-shadow: 0 6px 20px rgba(132, 0, 255, 0.5);
  animation: pulseMagnifier 2s ease-in-out infinite;
}

.magnifier-toggle.active::before {
  background: white;
  border-color: rgba(132, 0, 255, 1);
  animation: zoomInOut 1s ease-in-out infinite;
}

/* Tooltip on hover */
.magnifier-toggle:hover::after {
  content: attr(title);
  position: absolute;
  bottom: -35px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.9);
  color: white;
  padding: 5px 10px;
  border-radius: 5px;
  font-size: 11px;
  white-space: nowrap;
  z-index: 1000;
  pointer-events: none;
}

@keyframes pulseMagnifier {
  0%, 100% { box-shadow: 0 6px 20px rgba(132, 0, 255, 0.5); }
  50% { box-shadow: 0 6px 30px rgba(132, 0, 255, 0.8); }
}

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

.color-preset {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.3);
  flex-shrink: 0;
  position: relative;
}

/* Special border for white color preset - always visible */
.color-preset[data-color="255, 255, 255"] {
  border-color: #555;
}

.color-preset:hover {
  transform: scale(1.15);
  box-shadow: 0 5px 18px rgba(255, 255, 255, 0.2);
}

.color-preset.active {
  border-color: white;
  transform: scale(1.15);
  box-shadow: 0 6px 20px rgba(255, 255, 255, 0.3);
}

/* Keep visible border for white when active */
.color-preset[data-color="255, 255, 255"].active {
  border-color: #ddd;
  box-shadow: 0 0 0 2px white, 0 6px 20px rgba(255, 255, 255, 0.5);
}

/* Reset Button */
.reset-btn {
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, #210835 0%, #240727 100%);
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 15px;
}

.reset-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(149, 113, 248, 0.4);
}

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

.reset-btn i {
  font-size: 1.1rem;
}

/* Responsive Design */
@media (max-width: 1024px) {
  .bento-with-customizer {
    flex-direction: column;
  }
  
  .bento-customizer-wrapper {
    flex: 1;
    max-width: 100%;
    order: 2; /* تحريك الكستمايزر للأسفل */
  }
  
  .bento-cards-wrapper {
    order: 1; /* البطاقات في الأعلى */
  }
  
  .bento-customizer-panel {
    position: relative;
    top: 0;
    height: auto;
    margin-top: 20px;
  }
  
  .customizer-content {
    overflow-y: visible;
  }
  
  .customizer-switches {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
}

@media (max-width: 768px) {
  .bento-customizer-panel {
    padding: 15px;
  }
  
  .customizer-header h3 {
    font-size: 1.1rem;
  }
  
  .customizer-switches {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 599px) {
  .bento-with-customizer {
    flex-direction: column;
  }
  
  .bento-customizer-wrapper {
    order: 2; /* الكستمايزر تحت البطاقات */
    margin-top: 20px;
  }
  
  .bento-cards-wrapper {
    order: 1; /* البطاقات في الأعلى */
  }
  
  .customizer-switches {
    grid-template-columns: 1fr;
    gap: 8px;
  }
}

@media (max-width: 480px) {
  .control-label {
    flex-direction: column;
    align-items: flex-start;
    gap: 5px;
  }
  
  .color-presets {
    flex-wrap: wrap;
    gap: 5px;
  }
  
  .color-preset {
    width: 28px;
    height: 28px;
  }
  
  .magnifier-toggle {
    width: 28px;
    height: 28px;
  }
  
  .magnifier-toggle::before {
    width: 10px;
    height: 10px;
  }
  
  .magnifier-feedback-text {
    font-size: 11px;
    padding: 6px 12px;
    top: -40px;
  }
  
  .magnifier-progress-ring {
    border-width: 2px;
  }
}
