/**
 * RE::SPARKS Extension - Content Styles v2
 * =========================================
 * Gold highlights, corner icon, save buttons, toasts
 */

/* =============================================================================
   TEXT SELECTION (Orange/Sparks color)
   ============================================================================= */

::selection {
  background: rgba(255, 154, 0, 0.4) !important;
  color: inherit !important;
}

::-moz-selection {
  background: rgba(255, 154, 0, 0.4) !important;
  color: inherit !important;
}

/* =============================================================================
   CORNER SPARK ICON - Top Right Pulsing Button
   ============================================================================= */

#sparks-corner-icon {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 2147483647;
  cursor: pointer;
  opacity: 0;
  transform: scale(0.5);
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#sparks-corner-icon.visible {
  opacity: 1;
  transform: scale(1);
}

#sparks-corner-icon .sparks-icon-inner {
  width: 52px;
  height: 52px;
  background: #FFFFFF;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    0 4px 24px rgba(255, 154, 0, 0.5),
    0 0 0 3px rgba(255, 154, 0, 0.3);
  transition: all 0.2s ease;
  position: relative;
}

#sparks-corner-icon:hover .sparks-icon-inner {
  transform: scale(1.1);
  box-shadow:
    0 6px 32px rgba(255, 154, 0, 0.6),
    0 0 0 4px rgba(255, 154, 0, 0.4);
}

#sparks-corner-icon svg {
  width: 28px;
  height: 28px;
  stroke: #FF9A00;
  stroke-width: 2.5;
  fill: none;
}

#sparks-corner-icon .sparks-icon-count {
  position: absolute;
  top: -6px;
  right: -6px;
  background: #FF9A00;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  min-width: 22px;
  height: 22px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

/* Triple pulse animation rings */
#sparks-corner-icon .sparks-icon-pulse {
  position: absolute;
  top: 0;
  left: 0;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 3px solid #FF9A00;
  background: transparent;
  animation: sparksPulseRing 1.5s ease-out infinite;
  pointer-events: none;
}

#sparks-corner-icon .sparks-icon-pulse::before,
#sparks-corner-icon .sparks-icon-pulse::after {
  content: '';
  position: absolute;
  top: -3px;
  left: -3px;
  right: -3px;
  bottom: -3px;
  border-radius: 50%;
  border: 3px solid #FF9A00;
}

#sparks-corner-icon .sparks-icon-pulse::before {
  animation: sparksPulseRing 1.5s ease-out infinite 0.3s;
}

#sparks-corner-icon .sparks-icon-pulse::after {
  animation: sparksPulseRing 1.5s ease-out infinite 0.6s;
}

@keyframes sparksPulseRing {
  0% {
    transform: scale(1);
    opacity: 0.8;
  }
  100% {
    transform: scale(2);
    opacity: 0;
  }
}

/* Tooltip - now below the icon */
#sparks-corner-icon .sparks-icon-tooltip {
  position: absolute;
  top: 64px;
  right: 0;
  background: #1a1a1a;
  color: #fff;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.4;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.2s ease;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

#sparks-corner-icon .sparks-icon-tooltip::before {
  content: '';
  position: absolute;
  top: -6px;
  right: 20px;
  width: 12px;
  height: 12px;
  background: #1a1a1a;
  transform: rotate(45deg);
}

#sparks-corner-icon:hover .sparks-icon-tooltip {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

#sparks-corner-icon .sparks-icon-tooltip small {
  color: #888;
}

/* Analyzing state */
#sparks-corner-icon.analyzing .sparks-icon-inner {
  animation: sparksSpin 1.5s linear infinite;
}

#sparks-corner-icon.analyzing .sparks-icon-pulse,
#sparks-corner-icon.analyzing .sparks-icon-pulse::before,
#sparks-corner-icon.analyzing .sparks-icon-pulse::after {
  animation: none;
  opacity: 0;
}

@keyframes sparksSpin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Verified state - black on orange */
#sparks-corner-icon.verified .sparks-icon-inner {
  background: #FF9A00;
  box-shadow:
    0 4px 24px rgba(255, 154, 0, 0.6),
    0 0 0 3px rgba(255, 154, 0, 0.4);
}

#sparks-corner-icon.verified svg {
  stroke: #000000;
}

#sparks-corner-icon.verified .sparks-icon-count {
  background: #000000;
  color: #FF9A00;
}

#sparks-corner-icon.verified .sparks-icon-pulse,
#sparks-corner-icon.verified .sparks-icon-pulse::before,
#sparks-corner-icon.verified .sparks-icon-pulse::after {
  border-color: #FF9A00;
}

/* =============================================================================
   GOLD HIGHLIGHTS
   ============================================================================= */

.sparks-gold-highlight {
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.3) 0%, rgba(255, 165, 0, 0.3) 100%);
  border-bottom: 2px solid #FFB800;
  padding: 2px 0;
  cursor: pointer;
  position: relative;
  transition: all 0.2s ease;
  border-radius: 2px;
}

.sparks-gold-highlight:hover {
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.5) 0%, rgba(255, 165, 0, 0.5) 100%);
}

.sparks-gold-highlight.hidden {
  background: none;
  border-bottom: none;
}

/* Inline save button */
.sparks-inline-save {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  background: linear-gradient(135deg, #FFB800 0%, #FF6D00 100%);
  color: #000;
  border: none;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 4px 16px rgba(255, 109, 0, 0.3);
  opacity: 0;
  visibility: hidden;
  transform: translateY(5px);
  transition: all 0.2s ease;
  z-index: 2147483646;
}

.sparks-inline-save::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 16px;
  border: 6px solid transparent;
  border-top-color: #FF8F00;
}

.sparks-inline-save.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.sparks-inline-save:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(255, 109, 0, 0.4);
}

.sparks-inline-save.saved {
  background: linear-gradient(135deg, #00C853 0%, #00E676 100%);
  color: #fff;
}

/* =============================================================================
   TOAST NOTIFICATION
   ============================================================================= */

#sparks-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
  color: #fff;
  padding: 14px 20px;
  border-radius: 10px;
  font-size: 14px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 6px 30px rgba(0,0,0,0.3);
  z-index: 2147483647;
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.3s ease;
}

#sparks-toast.visible {
  opacity: 1;
  transform: translateY(0);
}

#sparks-toast svg {
  width: 20px;
  height: 20px;
  stroke: #00E676;
}

/* =============================================================================
   QUICK SAVE POPUP (on text selection)
   ============================================================================= */

.sparks-quick-popup {
  position: absolute;
  background: #f8f7f4;
  border-radius: 8px;
  box-shadow: 4px 8px 24px rgba(0,0,0,0.25), 2px 4px 8px rgba(0,0,0,0.15);
  z-index: 2147483647;
  overflow: hidden;
  max-width: 220px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  animation: sparksPopupIn 0.2s ease;
}

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

.sparks-popup-header {
  padding: 8px 12px;
  background: linear-gradient(135deg, #FFB800 0%, #FF6D00 100%);
  color: #fff;
  font-weight: 600;
  font-size: 13px;
  display: flex;
  align-items: center;
}

.sparks-popup-list {
  padding: 6px;
  max-height: 150px;
  overflow-y: auto;
  background: #f8f7f4;
}

.sparks-popup-list button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  background: none;
  border: none;
  border-radius: 5px;
  color: #333;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s ease;
  position: relative;
  overflow: hidden;
  white-space: nowrap;
}

.sparks-popup-list button::after {
  content: '';
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 30px;
  background: linear-gradient(to right, transparent, #f8f7f4);
  pointer-events: none;
}

.sparks-popup-list button:hover {
  background: rgba(255,154,0,0.1);
}

.sparks-popup-list button:hover {
  background: rgba(255,255,255,0.1);
}

.sparks-popup-list button span {
  width: 10px;
  height: 10px;
  flex-shrink: 0;
  border-radius: 3px;
  flex-shrink: 0;
}

/* =============================================================================
   MOBILE ADJUSTMENTS
   ============================================================================= */

@media (max-width: 768px) {
  #sparks-corner-icon {
    top: 12px;
    right: 12px;
  }

  #sparks-corner-icon .sparks-icon-inner {
    width: 44px;
    height: 44px;
  }

  #sparks-corner-icon .sparks-icon-pulse {
    width: 44px;
    height: 44px;
  }

  #sparks-corner-icon svg {
    width: 22px;
    height: 22px;
  }

  .sparks-quick-popup {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    border-radius: 16px 16px 0 0;
  }
}
