/**
 * TallyUps Help Tooltips Styles
 * =============================
 * Mobile-friendly, accessible tooltip styles.
 * Works with tooltips.js for a complete help system.
 */

/* =================================================================
   TOOLTIP CONTAINER
   ================================================================= */

.tallyups-tooltip {
  position: absolute;
  z-index: var(--z-tooltip, 350);
  max-width: 280px;
  padding: 0;

  /* Hidden by default */
  opacity: 0;
  visibility: hidden;
  transform: translateY(4px);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;

  /* Prevent interaction when hidden */
  pointer-events: none;
}

.tallyups-tooltip--visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}

/* Tooltip content box */
.tallyups-tooltip__content {
  background: var(--bg-elevated, #1e1e2d);
  border: 1px solid var(--border-primary, rgba(255, 255, 255, 0.15));
  border-radius: var(--radius-lg, 12px);
  padding: 12px 16px;
  padding-right: 36px; /* Space for close button */

  color: var(--text-primary, #f8fafc);
  font-size: 14px;
  line-height: 1.5;
  font-weight: 400;

  box-shadow:
    0 10px 25px -5px rgba(0, 0, 0, 0.4),
    0 4px 10px -2px rgba(0, 0, 0, 0.2);
}

/* Close button */
.tallyups-tooltip__close {
  position: absolute;
  top: 8px;
  right: 8px;

  width: 24px;
  height: 24px;
  padding: 0;

  display: flex;
  align-items: center;
  justify-content: center;

  background: transparent;
  border: none;
  border-radius: var(--radius-sm, 4px);

  color: var(--text-muted, #64748b);
  cursor: pointer;
  transition: all 0.15s ease;
}

.tallyups-tooltip__close:hover {
  background: var(--bg-hover, rgba(255, 255, 255, 0.1));
  color: var(--text-primary, #f8fafc);
}

.tallyups-tooltip__close:focus {
  outline: 2px solid var(--brand-primary, #00ff88);
  outline-offset: 1px;
}

.tallyups-tooltip__close svg {
  width: 14px;
  height: 14px;
}

/* =================================================================
   HELP ICON (question mark button)
   ================================================================= */

.help-tooltip {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  width: 18px;
  height: 18px;
  margin-left: 6px;

  background: var(--bg-tertiary, rgba(255, 255, 255, 0.08));
  border: 1px solid var(--border-secondary, rgba(255, 255, 255, 0.1));
  border-radius: 50%;

  color: var(--text-muted, #64748b);
  font-size: 11px;
  font-weight: 600;
  font-family: inherit;
  line-height: 1;

  cursor: help;
  transition: all 0.15s ease;

  /* Reset button styles */
  padding: 0;
  text-decoration: none;
}

.help-tooltip:hover {
  background: var(--brand-primary-dim, rgba(0, 255, 136, 0.15));
  border-color: var(--brand-primary, #00ff88);
  color: var(--brand-primary, #00ff88);
  transform: scale(1.1);
}

.help-tooltip:focus {
  outline: 2px solid var(--brand-primary, #00ff88);
  outline-offset: 2px;
  background: var(--brand-primary-dim, rgba(0, 255, 136, 0.15));
}

/* Larger size variant */
.help-tooltip--lg {
  width: 22px;
  height: 22px;
  font-size: 13px;
}

/* In-label positioning */
label .help-tooltip,
.form-group label .help-tooltip {
  vertical-align: middle;
  margin-left: 4px;
}

/* =================================================================
   ELEMENTS WITH TOOLTIPS
   ================================================================= */

/* Add subtle indicator for elements with tooltips */
[data-tooltip],
[data-help-key] {
  cursor: help;
}

/* Optional: Add underline style for text elements */
.tooltip-underline[data-tooltip],
.tooltip-underline[data-help-key] {
  border-bottom: 1px dashed var(--text-muted, #64748b);
}

.tooltip-underline[data-tooltip]:hover,
.tooltip-underline[data-help-key]:hover {
  border-bottom-color: var(--brand-primary, #00ff88);
}

/* =================================================================
   TOOLTIP POSITIONS
   ================================================================= */

/* Arrow/pointer for tooltips - hidden by default, can be enabled */
.tallyups-tooltip::before {
  content: '';
  position: absolute;
  width: 10px;
  height: 10px;
  background: inherit;
  border: inherit;
  transform: rotate(45deg);
  display: none; /* Hide arrows for cleaner look */
}

/* Enable arrows with this class */
.tallyups-tooltip--with-arrow::before {
  display: block;
}

/* Position-specific arrow placement */
.tallyups-tooltip[data-actual-position="top"]::before {
  bottom: -5px;
  left: 50%;
  margin-left: -5px;
  border-top: none;
  border-left: none;
}

.tallyups-tooltip[data-actual-position="bottom"]::before {
  top: -5px;
  left: 50%;
  margin-left: -5px;
  border-bottom: none;
  border-right: none;
}

.tallyups-tooltip[data-actual-position="left"]::before {
  right: -5px;
  top: 50%;
  margin-top: -5px;
  border-bottom: none;
  border-left: none;
}

.tallyups-tooltip[data-actual-position="right"]::before {
  left: -5px;
  top: 50%;
  margin-top: -5px;
  border-top: none;
  border-right: none;
}

/* =================================================================
   MOBILE STYLES
   ================================================================= */

@media (max-width: 768px) {
  .tallyups-tooltip {
    max-width: calc(100vw - 40px);
    left: 20px !important;
    right: 20px;
    width: auto;
  }

  .tallyups-tooltip__content {
    font-size: 15px;
    padding: 14px 18px;
    padding-right: 40px;
  }

  .tallyups-tooltip__close {
    width: 28px;
    height: 28px;
    top: 10px;
    right: 10px;
  }

  .tallyups-tooltip__close svg {
    width: 16px;
    height: 16px;
  }

  /* Larger touch target for help icons on mobile */
  .help-tooltip {
    width: 24px;
    height: 24px;
    font-size: 13px;
    margin-left: 8px;
  }

  /* Ensure tappable area is large enough */
  .help-tooltip::after {
    content: '';
    position: absolute;
    top: -8px;
    right: -8px;
    bottom: -8px;
    left: -8px;
  }
}

/* =================================================================
   LIGHT THEME SUPPORT
   ================================================================= */

[data-theme="light"] .tallyups-tooltip__content {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.12);
  color: #0f172a;
  box-shadow:
    0 10px 25px -5px rgba(0, 0, 0, 0.15),
    0 4px 10px -2px rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .tallyups-tooltip__close {
  color: #94a3b8;
}

[data-theme="light"] .tallyups-tooltip__close:hover {
  background: rgba(0, 0, 0, 0.05);
  color: #0f172a;
}

[data-theme="light"] .help-tooltip {
  background: rgba(0, 0, 0, 0.05);
  border-color: rgba(0, 0, 0, 0.1);
  color: #64748b;
}

[data-theme="light"] .help-tooltip:hover {
  background: rgba(0, 212, 170, 0.1);
  border-color: #00d4aa;
  color: #00b894;
}

/* =================================================================
   ANIMATION VARIANTS
   ================================================================= */

/* Fade only (no movement) */
.tallyups-tooltip--fade-only {
  transform: none;
}

.tallyups-tooltip--fade-only.tallyups-tooltip--visible {
  transform: none;
}

/* Scale effect */
.tallyups-tooltip--scale {
  transform: scale(0.95);
}

.tallyups-tooltip--scale.tallyups-tooltip--visible {
  transform: scale(1);
}

/* =================================================================
   REDUCED MOTION SUPPORT
   ================================================================= */

@media (prefers-reduced-motion: reduce) {
  .tallyups-tooltip {
    transition: opacity 0.1s ease, visibility 0.1s;
    transform: none;
  }

  .tallyups-tooltip--visible {
    transform: none;
  }

  .help-tooltip {
    transition: none;
  }

  .help-tooltip:hover {
    transform: none;
  }
}

/* =================================================================
   HIGH CONTRAST MODE
   ================================================================= */

@media (prefers-contrast: high) {
  .tallyups-tooltip__content {
    border-width: 2px;
    border-color: currentColor;
  }

  .help-tooltip {
    border-width: 2px;
  }

  .help-tooltip:focus {
    outline-width: 3px;
  }
}

/* =================================================================
   PRINT STYLES
   ================================================================= */

@media print {
  .tallyups-tooltip,
  .help-tooltip {
    display: none !important;
  }
}

/* =================================================================
   UTILITY CLASSES
   ================================================================= */

/* Hide tooltip trigger on specific breakpoints */
.help-tooltip--hide-mobile {
  display: none;
}

@media (min-width: 769px) {
  .help-tooltip--hide-mobile {
    display: inline-flex;
  }
}

.help-tooltip--hide-desktop {
  display: inline-flex;
}

@media (min-width: 1024px) {
  .help-tooltip--hide-desktop {
    display: none;
  }
}

/* Position helper classes for inline help icons */
.help-tooltip--inline {
  vertical-align: text-bottom;
}

.help-tooltip--superscript {
  vertical-align: super;
  font-size: 9px;
  width: 14px;
  height: 14px;
}
