/* Help Tooltip System */

/* Define RGB values for backdrop-filter support */
:root {
    --tooltip-bg-dark: rgba(24, 24, 28, 0.95);
    --tooltip-bg-light: rgba(255, 255, 255, 0.98);
    --tooltip-border-dark: rgba(255, 255, 255, 0.1);
    --tooltip-border-light: rgba(0, 0, 0, 0.08);
}

/* Hide original helper text by default */
.input-helper {
    display: none !important;
}

/* Help Icon Button */
.help-icon-btn {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    padding: 0;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    opacity: 0.6;
    transition: all 0.2s ease;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Adjust positioning for inputs with success icons */
.input-group.success .help-icon-btn {
    right: 36px; /* Move left to make room for success icon */
}

/* Password inputs need special positioning */
.password-input-group .help-icon-btn {
    position: absolute !important;
    right: 44px !important; /* Account for password toggle */
    top: 50% !important;
    transform: translateY(-50%) !important;
    z-index: 4;
}

.password-input-group.success .help-icon-btn {
    right: 68px !important; /* Account for both password toggle and success icon */
}

/* Phone input special positioning */
.phone-input-redesign .help-icon-btn {
    position: absolute;
    right: 12px;
    top: 32px; /* Adjusted for phone input structure */
}

.phone-input-redesign.success .help-icon-btn {
    right: 36px;
}

.help-icon-btn:hover {
    opacity: 1;
    color: var(--primary-2);
    transform: translateY(-50%) scale(1.1);
}

.help-icon-btn:focus {
    outline: none;
    opacity: 1;
}

/* SVG Icon */
.help-icon-btn svg {
    width: 100%;
    height: 100%;
}

/* Tooltip Container */
.help-tooltip {
    position: absolute;
    bottom: calc(100% + 8px);
    right: 0;
    min-width: 280px;
    max-width: 320px;
    padding: 12px 16px;
    background: var(--tooltip-bg-dark);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border: 1px solid var(--tooltip-border-dark);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25), 
                0 0 0 1px rgba(255, 255, 255, 0.05) inset,
                0 2px 8px rgba(0, 0, 0, 0.3);
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    z-index: 1000;
    pointer-events: none;
}

/* Fallback for browsers without backdrop-filter support */
@supports not (backdrop-filter: blur(16px)) {
    .help-tooltip {
        background: rgba(24, 24, 28, 0.98);
    }
    
    [data-theme="light"] .help-tooltip {
        background: rgba(255, 255, 255, 0.98);
    }
}

/* Active state */
.help-icon-btn.active + .help-tooltip,
.help-tooltip:hover {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
}

/* Tooltip Arrow */
.help-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    right: 16px;
    width: 0;
    height: 0;
    border: 6px solid transparent;
    border-top-color: var(--border-default);
    transform: translateX(50%);
}

.help-tooltip::before {
    content: '';
    position: absolute;
    top: 100%;
    right: 16px;
    width: 0;
    height: 0;
    border: 6px solid transparent;
    border-top-color: var(--bg-elevated);
    transform: translateX(50%) translateY(-1px);
    z-index: 1;
}

/* Tooltip Content */
.help-tooltip-content {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.help-tooltip-icon {
    flex-shrink: 0;
    font-size: 16px;
    margin-top: 2px;
}

.help-tooltip-text {
    font-size: 13px;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    font-weight: 400;
    letter-spacing: 0.01em;
}

[data-theme="light"] .help-tooltip-text {
    color: rgba(0, 0, 0, 0.85);
    text-shadow: none;
}

/* Light theme adjustments */
[data-theme="light"] .help-tooltip {
    background: var(--tooltip-bg-light);
    border: 1px solid var(--tooltip-border-light);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15), 
                0 0 0 1px rgba(255, 255, 255, 0.9) inset,
                0 2px 8px rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .help-icon-btn {
    color: rgba(0, 0, 0, 0.4);
}

[data-theme="light"] .help-icon-btn:hover {
    color: var(--primary-2);
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .help-tooltip {
        min-width: 240px;
        max-width: 280px;
        right: auto;
        left: 50%;
        transform: translateX(-50%) translateY(8px);
    }
    
    .help-icon-btn.active + .help-tooltip {
        transform: translateX(-50%) translateY(0);
    }
    
    .help-tooltip::after,
    .help-tooltip::before {
        right: auto;
        left: 50%;
        transform: translateX(-50%);
    }
    
    .help-tooltip::before {
        transform: translateX(-50%) translateY(-1px);
    }
}

/* Adjust input padding to make room for help icon */
.input-group input {
    padding-right: 40px; /* Make room for help icon */
}

.input-group.success input {
    padding-right: 64px; /* Room for both help and success icons */
}

.password-input-group input {
    padding-right: 72px !important; /* Room for help icon and password toggle */
}

.password-input-group.success input {
    padding-right: 96px !important; /* Room for all three icons */
}

/* Ensure phone input doesn't get affected */
.phone-input-redesign .phone-number-input {
    padding-right: 16px !important; /* Keep original padding */
}

/* Animation for tooltip */
@keyframes tooltipPulse {
    0% {
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    }
    50% {
        box-shadow: 0 8px 32px rgba(102, 126, 234, 0.15);
    }
    100% {
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    }
}

.help-tooltip:hover {
    animation: tooltipPulse 2s ease-in-out infinite;
}

/* Close button for mobile tooltips */
.help-tooltip-close {
    display: none;
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    padding: 0;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    opacity: 0.6;
    transition: opacity 0.2s ease;
}

@media (max-width: 768px) {
    .help-tooltip-close {
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .help-tooltip-content {
        padding-right: 20px;
    }
}

.help-tooltip-close:hover {
    opacity: 1;
}

.help-tooltip-close svg {
    width: 16px;
    height: 16px;
}