/* Tooltip System - Pretty tooltips for better UX
 *
 * CURSORRULES:
 * When adding new features to the website or admin panel, they MUST be very accessible:
 * - Add helpful tooltips using data-tooltip attributes with clear explanations
 * - Include useful placeholder text with examples in input fields
 * - Use tooltip-wrapper class on labels to provide context
 * - Tooltips should explain what the field is for, how to use it, and provide examples
 * - Placeholders should show the expected format or example values
 */

/* Tooltip container */
.tooltip-wrapper {
  position: relative;
  display: inline-block;
  vertical-align: middle;
  cursor: pointer;
}

/* Elements with no icon should use default cursor */
.tooltip-wrapper[data-tooltip-no-icon] {
  cursor: default !important;
}

/* Override cursor for buttons with tooltips - always pointer */
button.tooltip-wrapper,
button.tooltip-wrapper[data-tooltip-no-icon] {
  cursor: pointer !important;
}

/* Ensure empty tooltip-wrapper spans are visible */
.tooltip-wrapper:empty {
  display: inline-block;
  min-width: 18px;
  min-height: 18px;
}

.tooltip-wrapper .tooltip-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  margin-left: 6px;
  color: #6c757d;
  font-size: 12px;
  border-radius: 50%;
  background-color: rgba(108, 117, 125, 0.1);
  transition: all 0.2s ease;
  vertical-align: middle;
  line-height: 1;
}

.tooltip-wrapper:hover .tooltip-icon,
.tooltip-wrapper:focus .tooltip-icon {
  color: #495057;
  background-color: rgba(108, 117, 125, 0.2);
}

/* Dark theme tooltip icon */
body.theme-dark .tooltip-wrapper .tooltip-icon {
  color: #adb5bd;
  background-color: rgba(173, 181, 189, 0.15);
}

body.theme-dark .tooltip-wrapper:hover .tooltip-icon,
body.theme-dark .tooltip-wrapper:focus .tooltip-icon {
  color: #ced4da;
  background-color: rgba(173, 181, 189, 0.25);
}

/* Tooltip bubble */
.tooltip-bubble {
  position: fixed;
  z-index: 50000;
  padding: 10px 14px;
  background-color: #2d3748;
  color: #ffffff;
  font-size: 13px;
  line-height: 1.5;
  border-radius: 6px;
  box-shadow:
    0 4px 12px rgba(0, 0, 0, 0.15),
    0 0 0 1px rgba(0, 0, 0, 0.1);
  max-width: 300px;
  min-width: 150px;
  width: auto;
  white-space: normal;
  word-wrap: break-word;
  overflow-wrap: break-word;
  box-sizing: border-box;
  opacity: 0;
  visibility: hidden;
  display: none;
  transform: translateY(-8px) scale(0.95);
  transition:
    opacity 0.18s cubic-bezier(0.4, 0, 0.2, 1),
    transform 0.18s cubic-bezier(0.4, 0, 0.2, 1),
    visibility 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}

/* Show state with smooth animation */
.tooltip-bubble.show {
  opacity: 1;
  visibility: visible;
  display: block;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Tooltip arrow */
.tooltip-bubble::before {
  content: '';
  position: absolute;
  width: 0;
  height: 0;
  border-style: solid;
  pointer-events: none;
}

/* Tooltip positioning - default (top) */
/* Note: Positioning is now handled by JavaScript for fixed positioning */
.tooltip-bubble.tooltip-top {
  transform: translateY(-8px) scale(0.95);
}

.tooltip-bubble.tooltip-top.show {
  transform: translateY(0) scale(1);
}

.tooltip-bubble.tooltip-top::before {
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  border-width: 6px 6px 0 6px;
  border-color: #2d3748 transparent transparent transparent;
}

/* Tooltip positioning - bottom */
.tooltip-bubble.tooltip-bottom {
  transform: translateY(8px) scale(0.95);
}

.tooltip-bubble.tooltip-bottom.show {
  transform: translateY(0) scale(1);
}

.tooltip-bubble.tooltip-bottom::before {
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  border-width: 0 6px 6px 6px;
  border-color: transparent transparent #2d3748 transparent;
}

/* Tooltip positioning - left */
.tooltip-bubble.tooltip-left {
  transform: translateX(-8px) scale(0.95);
}

.tooltip-bubble.tooltip-left.show {
  transform: translateX(0) scale(1);
}

.tooltip-bubble.tooltip-left::before {
  right: -6px;
  top: 50%;
  transform: translateY(-50%);
  border-width: 6px 0 6px 6px;
  border-color: transparent transparent transparent #2d3748;
}

/* Tooltip positioning - right */
.tooltip-bubble.tooltip-right {
  transform: translateX(8px) scale(0.95);
}

.tooltip-bubble.tooltip-right.show {
  transform: translateX(0) scale(1);
}

.tooltip-bubble.tooltip-right::before {
  left: -6px;
  top: 50%;
  transform: translateY(-50%);
  border-width: 6px 6px 6px 0;
  border-color: transparent #2d3748 transparent transparent;
}

/* Dark theme tooltip bubble */
body.theme-dark .tooltip-bubble {
  background-color: #1a202c;
  color: #e2e8f0;
  box-shadow:
    0 4px 12px rgba(0, 0, 0, 0.3),
    0 0 0 1px rgba(255, 255, 255, 0.1);
}

body.theme-dark .tooltip-bubble.tooltip-top::before {
  border-color: #1a202c transparent transparent transparent;
}

body.theme-dark .tooltip-bubble.tooltip-bottom::before {
  border-color: transparent transparent #1a202c transparent;
}

body.theme-dark .tooltip-bubble.tooltip-left::before {
  border-color: transparent transparent transparent #1a202c;
}

body.theme-dark .tooltip-bubble.tooltip-right::before {
  border-color: transparent #1a202c transparent transparent;
}

/* Tooltip title (optional) */
.tooltip-bubble .tooltip-title {
  font-weight: 600;
  margin-bottom: 6px;
  font-size: 14px;
  color: #ffffff;
  display: block;
  width: 100%;
}

body.theme-dark .tooltip-bubble .tooltip-title {
  color: #f7fafc;
}

/* Tooltip content */
.tooltip-bubble .tooltip-content {
  color: #e2e8f0;
  display: block;
  width: 100%;
}

body.theme-dark .tooltip-bubble .tooltip-content {
  color: #cbd5e0;
}

/* Tooltip with example */
.tooltip-bubble .tooltip-example {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
  font-size: 12px;
  font-style: italic;
  color: #a0aec0;
  display: block;
  width: 100%;
}

body.theme-dark .tooltip-bubble .tooltip-example {
  border-top-color: rgba(255, 255, 255, 0.1);
  color: #718096;
}

/* Tooltip on labels */
label .tooltip-wrapper {
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
}

/* Ensure tooltip-wrapper spans inside labels are visible */
label .tooltip-wrapper:empty {
  display: inline-flex;
  min-width: 18px;
  min-height: 18px;
  align-items: center;
}

/* Tooltip on badges */
.issue-badge,
.menu-badge,
.nav-warning-badge {
  position: relative;
}

/* Badges should not have pointer cursor even with tooltips */
.menu-badge.tooltip-wrapper,
.issue-badge.tooltip-wrapper,
.nav-warning-badge.tooltip-wrapper {
  cursor: default !important;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .tooltip-bubble {
    max-width: 250px;
    min-width: 120px;
    width: auto;
    font-size: 12px;
  }

  /* On mobile, tooltip positioning is handled by JavaScript */
  .tooltip-bubble.tooltip-left,
  .tooltip-bubble.tooltip-right {
    transform: translateY(5px);
  }

  .tooltip-bubble.tooltip-left.show,
  .tooltip-bubble.tooltip-right.show {
    transform: translateY(0);
  }
}
