/**
 * Pricing Page Tooltips Styles
 * 
 * WCAG 2.2 compliant tooltip implementation for pricing page features.
 * Matches Ordio branding and design system.
 */

/* Tooltip Wrapper */
.pricing-feature-tooltip-wrapper {
    position: relative;
    width: 100%;
    align-items: center; /* Center align for proper baseline alignment */
}

/* Ensure proper spacing between checkmark and content */
.pricing-feature-tooltip-wrapper > .flex-shrink-0 {
    /* No margin-top needed - center alignment handles positioning */
}

/*
 * Tooltip container — scoped to pricing cards only.
 * Comparison table + sticky header use the same class with Tailwind md:hidden
 * to hide redundant info icons on desktop; a global .pricing-tooltip-container
 * { display: flex } rule would override md:hidden and keep icons visible.
 */
.pricing-feature-tooltip-wrapper .pricing-tooltip-container {
    position: relative;
    display: flex;
    align-items: center; /* Center align for proper baseline alignment with text */
    justify-content: flex-end;
    flex-shrink: 0;
}

/* Tooltip Trigger Button */
.pricing-tooltip-trigger {
    flex-shrink: 0;
    touch-action: manipulation; /* Prevent double-tap zoom on mobile */
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.pricing-tooltip-trigger:focus-visible {
    outline: 2px solid #4D8EF3;
    outline-offset: 2px;
    border-radius: 50%;
}

/* Tooltip Icon */
.pricing-tooltip-icon {
    transition: color 0.2s cubic-bezier(0.4, 0, 0.2, 1), transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.pricing-tooltip-trigger:hover .pricing-tooltip-icon,
.pricing-tooltip-trigger:focus .pricing-tooltip-icon {
    color: #4D8EF3;
    transform: scale(1.1);
}

.pricing-tooltip-trigger[aria-expanded="true"] .pricing-tooltip-icon {
    color: #4D8EF3;
}

/* Tooltip Content Container */
.pricing-tooltip-content {
    position: fixed !important;
    z-index: 2147483647 !important; /* Maximum z-index value */
    pointer-events: none;
    
    /* Initially hidden - position will be set by JavaScript */
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: opacity 0.2s cubic-bezier(0.4, 0, 0.2, 1),
                visibility 0.2s cubic-bezier(0.4, 0, 0.2, 1),
                transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Prevent layout shift */
    will-change: opacity, transform;
    
    /* Ensure no height constraints on container - let content determine height */
    height: auto !important;
    max-height: none !important;
    
    /* CRITICAL: Prevent any overflow on the container itself */
    overflow: visible !important;
    overflow-x: visible !important;
    overflow-y: visible !important;
}

/* Tooltip Visible State */
.pricing-tooltip-content[aria-hidden="false"] {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
}

/* Tooltip Inner Content */
.pricing-tooltip-inner {
    background-color: #FFFFFF;
    color: #374151;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 0.875rem; /* 14px */
    line-height: 1.5;
    max-width: 320px;
    min-width: 200px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1),
                0 10px 10px -5px rgba(0, 0, 0, 0.04);
    word-wrap: break-word;
    white-space: normal;
    text-align: left;
}

/* Tooltip Arrow */
.pricing-tooltip-arrow {
    position: absolute;
    bottom: -6px;
    left: 20px;
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid #FFFFFF;
    filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.1));
}

/* Mobile Optimizations */
@media (max-width: 640px) {
    .pricing-tooltip-content {
        /* Full width on mobile for better readability - JS will override positioning */
        width: calc(100vw - 2rem);
        max-width: calc(100vw - 2rem);
        /* left/right positioning handled by JavaScript for proper viewport boundary detection */
    }
    
    .pricing-tooltip-inner {
        max-width: 100%;
        min-width: auto;
        padding: 14px 18px;
        font-size: 0.875rem;
        /* Default: no height constraints, no overflow - show full content */
        overflow: visible !important; /* Default to visible - no scrollbar unless content overflows */
        overflow-x: visible !important;
        overflow-y: visible !important;
        max-height: none !important; /* No max-height by default - JavaScript will set if needed */
        height: auto !important; /* Natural height */
        /* CRITICAL: Prevent any inherited overflow behavior */
        -webkit-overflow-scrolling: auto !important;
    }
    
    .pricing-tooltip-arrow {
        left: 50%;
        transform: translateX(-50%);
    }
    
    /* Larger touch target on mobile - maintain consistent alignment */
    .pricing-tooltip-trigger {
        width: 44px;
        height: 44px;
        min-width: 44px; /* Ensure consistent width */
    }
    
    .pricing-tooltip-icon {
        width: 20px;
        height: 20px;
    }
    
    /* Ensure tooltip container maintains consistent right alignment (pricing cards only) */
    .pricing-feature-tooltip-wrapper .pricing-tooltip-container {
        min-width: 44px; /* Match trigger button width for consistent column */
        justify-content: flex-end;
    }
    
    /* Ensure proper alignment on mobile */
    .pricing-feature-tooltip-wrapper {
        align-items: center; /* Center align for consistent baseline */
    }
    
    /* Ensure text doesn't overflow and wraps properly */
    .pricing-feature-tooltip-wrapper .flex-1 {
        min-width: 0; /* Allow flex item to shrink below content size */
    }
    
    /* Improve spacing between text and tooltip icon on mobile */
    .pricing-feature-tooltip-wrapper .flex-1 > .flex-1 {
        padding-right: 0.5rem; /* Add spacing before tooltip icon */
    }
    
    /* Ensure tooltip icon aligns with text baseline for single-line features (pricing cards) */
    .pricing-feature-tooltip-wrapper .pricing-tooltip-container {
        align-items: center; /* Center align to match text baseline for single-line features */
    }
    
    /* Fine-tune tooltip icon vertical position to align with text center */
    .pricing-tooltip-trigger {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        /* Center alignment ensures proper baseline alignment with text */
    }
    
    /* Better text wrapping for long feature names */
    .pricing-feature-tooltip-wrapper span {
        word-break: break-word;
        hyphens: auto;
        overflow-wrap: break-word;
    }
}

/* Tablet Optimizations */
@media (min-width: 641px) and (max-width: 1024px) {
    .pricing-tooltip-inner {
        max-width: 280px;
    }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .pricing-tooltip-inner {
        border: 2px solid #374151;
    }
    
    .pricing-tooltip-icon {
        stroke-width: 2.5px;
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    .pricing-tooltip-content,
    .pricing-tooltip-icon,
    .pricing-tooltip-trigger {
        transition: none;
    }
    
    .pricing-tooltip-content {
        transform: none;
    }
}

/* Focus Visible for Keyboard Navigation */
.pricing-tooltip-trigger:focus-visible {
    outline: 2px solid #4D8EF3;
    outline-offset: 2px;
}

/* Screen Reader Only Text */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}
