/* ==========================================================================
   Genie Effect - Chatbot Icon with Auto Theme Cycling
   Mimics macOS dock minimize effect
   IMPORTANT: All styles use !important to persist across theme changes
   ========================================================================== */

/* Chatbot Icon - Fixed Right Bottom Corner */
.genie-icon {
  position: fixed !important;
  right: 20px !important;
  bottom: 30px !important;
  width: 80px !important;
  height: 80px !important;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
  border-radius: 20px !important;
  cursor: pointer !important;
  z-index: 10000 !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 4px !important;
  box-shadow:
    0 4px 15px rgba(102, 126, 234, 0.4),
    0 2px 6px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.3) !important;
  transition: transform 0.2s ease, box-shadow 0.2s ease !important;
  overflow: visible !important;
  font-family: Arial, sans-serif !important;
}

.genie-icon::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 50%;
  background: linear-gradient(to bottom, rgba(255,255,255,0.3) 0%, transparent 100%);
  border-radius: 16px 16px 0 0;
}

.genie-icon:hover {
  transform: scale(1.1);
  box-shadow:
    0 6px 20px rgba(102, 126, 234, 0.5),
    0 4px 10px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.genie-icon:active {
  transform: scale(0.95);
}

/* Chat bubble icon */
.genie-icon__svg {
  width: 32px !important;
  height: 32px !important;
  fill: #ffffff !important;
  position: relative !important;
  z-index: 1 !important;
}

/* Year display */
.genie-year {
  font-size: 14px !important;
  font-weight: bold !important;
  color: #ffffff !important;
  font-family: Arial, sans-serif !important;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3) !important;
  z-index: 1 !important;
  line-height: 1 !important;
}

/* Pulsing ring when auto-cycling */
.genie-icon--active::after {
  content: '';
  position: absolute;
  top: -4px;
  left: -4px;
  right: -4px;
  bottom: -4px;
  border: 2px solid rgba(102, 126, 234, 0.6);
  border-radius: 20px;
  animation: genie-pulse 1.5s ease-in-out infinite;
}

@keyframes genie-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.15); opacity: 0.5; }
}

/* Mini theme preview in icon */
.genie-icon__preview {
  position: absolute;
  top: 4px;
  left: 4px;
  right: 4px;
  bottom: 4px;
  border-radius: 12px;
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.genie-icon--has-preview .genie-icon__preview {
  opacity: 1;
}

.genie-icon--has-preview .genie-icon__svg {
  opacity: 0;
}

/* Genie Effect Overlay */
.genie-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 9999;
  pointer-events: none;
  perspective: 1000px;
}

.genie-capture {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  transform-origin: left bottom;
  background-size: cover;
  background-position: center;
  will-change: transform, opacity, clip-path;
}

/* Genie minimize animation - smooth flow to bottom-right corner */
.genie-capture--minimizing {
  animation: genie-minimize 1.8s cubic-bezier(0.25, 0.1, 0.25, 1) forwards;
  transform-origin: right bottom;
}

@keyframes genie-minimize {
  0% {
    transform: perspective(1200px) rotateX(0deg) rotateY(0deg) scale(1) translate(0, 0);
    clip-path: polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%);
    opacity: 1;
    filter: blur(0px);
  }
  20% {
    transform: perspective(1200px) rotateX(2deg) rotateY(-2deg) scale(0.95) translate(2%, 2%);
    clip-path: polygon(2% 0%, 100% 0%, 100% 100%, 5% 100%);
    opacity: 1;
    filter: blur(0px);
  }
  40% {
    transform: perspective(1200px) rotateX(5deg) rotateY(-5deg) scale(0.75) translate(8%, 10%);
    clip-path: polygon(8% 0%, 100% 0%, 100% 100%, 15% 100%);
    opacity: 0.95;
    filter: blur(0.5px);
  }
  60% {
    transform: perspective(1200px) rotateX(10deg) rotateY(-10deg) scale(0.45) translate(25%, 25%);
    clip-path: polygon(20% 0%, 100% 0%, 100% 100%, 35% 100%);
    opacity: 0.85;
    filter: blur(1px);
  }
  80% {
    transform: perspective(1200px) rotateX(15deg) rotateY(-15deg) scale(0.2) translate(55%, 50%);
    clip-path: polygon(35% 0%, 100% 0%, 100% 100%, 50% 100%);
    opacity: 0.5;
    filter: blur(2px);
  }
  100% {
    transform: perspective(1200px) rotateX(20deg) rotateY(-20deg) scale(0.02) translate(95%, 85%);
    clip-path: polygon(48% 0%, 100% 0%, 100% 100%, 52% 100%);
    opacity: 0;
    filter: blur(4px);
  }
}

/* Genie restore animation - smooth emergence from bottom-right */
.genie-capture--restoring {
  animation: genie-restore 1.5s cubic-bezier(0.25, 0.1, 0.25, 1) forwards;
  transform-origin: right bottom;
}

@keyframes genie-restore {
  0% {
    transform: perspective(1200px) rotateX(20deg) rotateY(-20deg) scale(0.02) translate(95%, 85%);
    clip-path: polygon(48% 0%, 100% 0%, 100% 100%, 52% 100%);
    opacity: 0;
    filter: blur(4px);
  }
  30% {
    transform: perspective(1200px) rotateX(12deg) rotateY(-12deg) scale(0.3) translate(40%, 40%);
    clip-path: polygon(25% 0%, 100% 0%, 100% 100%, 40% 100%);
    opacity: 0.6;
    filter: blur(2px);
  }
  60% {
    transform: perspective(1200px) rotateX(5deg) rotateY(-5deg) scale(0.7) translate(10%, 12%);
    clip-path: polygon(10% 0%, 100% 0%, 100% 100%, 18% 100%);
    opacity: 0.9;
    filter: blur(0.5px);
  }
  100% {
    transform: perspective(1200px) rotateX(0deg) rotateY(0deg) scale(1) translate(0, 0);
    clip-path: polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%);
    opacity: 1;
    filter: blur(0px);
  }
}

/* Tooltip */
.genie-tooltip {
  position: fixed !important;
  right: 110px !important;
  bottom: 55px !important;
  background: rgba(0, 0, 0, 0.85) !important;
  color: #ffffff !important;
  padding: 8px 14px !important;
  border-radius: 8px !important;
  font-size: 13px !important;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
  white-space: nowrap !important;
  opacity: 0 !important;
  transform: translateX(10px) !important;
  transition: opacity 0.2s ease, transform 0.2s ease !important;
  pointer-events: none !important;
  z-index: 10001 !important;
}

.genie-tooltip::after {
  content: '';
  position: absolute;
  right: -6px;
  top: 50%;
  transform: translateY(-50%);
  border: 6px solid transparent;
  border-left-color: rgba(0, 0, 0, 0.85);
}

.genie-icon:hover + .genie-tooltip,
.genie-tooltip--visible {
  opacity: 1;
  transform: translateX(0);
}

/* Status indicator */
.genie-status {
  position: fixed !important;
  right: 110px !important;
  bottom: 30px !important;
  background: rgba(0, 0, 0, 0.75) !important;
  color: #ffffff !important;
  padding: 6px 12px !important;
  border-radius: 6px !important;
  font-size: 11px !important;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
  opacity: 0 !important;
  transition: opacity 0.3s ease !important;
  z-index: 10001 !important;
}

.genie-status--visible {
  opacity: 1 !important;
}

/* Progress ring around icon */
.genie-progress {
  position: absolute !important;
  top: -6px !important;
  left: -6px !important;
  width: 92px !important;
  height: 92px !important;
  pointer-events: none !important;
  display: block !important;
}

.genie-progress__circle {
  fill: none !important;
  stroke: rgba(255, 255, 255, 0.9) !important;
  stroke-width: 3 !important;
  stroke-linecap: round !important;
  stroke-dasharray: 276 !important;
  stroke-dashoffset: 276 !important;
  transform: rotate(-90deg) !important;
  transform-origin: center !important;
  transition: stroke-dashoffset 0.1s linear !important;
}

/* Theme counter badge */
.genie-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  width: 22px;
  height: 22px;
  background: #ef4444;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: bold;
  color: #ffffff;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  z-index: 2;
}

/* Mobile adjustments */
@media (max-width: 768px) {
  .genie-icon {
    right: 10px;
    bottom: 20px;
    width: 50px;
    height: 50px;
    border-radius: 12px;
  }

  .genie-icon__svg {
    width: 26px;
    height: 26px;
  }

  .genie-tooltip {
    right: 70px;
    bottom: 35px;
    font-size: 12px;
  }

  .genie-progress {
    width: 60px;
    height: 60px;
  }

  .genie-badge {
    width: 18px;
    height: 18px;
    font-size: 10px;
  }
}
