/**
 * DPE Tooltip Styles
 * Portable tooltip system - can be copied to any project
 * 
 * @version 1.0.0
 */

/* Base tooltip trigger styles */
.dpe-tooltip-trigger {
    position: relative;
    display: inline-block;
    cursor: help;
}

/* Info icon styling */
.dpe-tooltip-icon {
    display: inline-block;
    width: 16px;
    height: 16px;
    line-height: 16px;
    text-align: center;
    font-size: 12px;
    font-weight: bold;
    color: #6b7280;
    background: #f3f4f6;
    border-radius: 50%;
    margin-left: 4px;
    vertical-align: middle;
    cursor: help;
    transition: all 0.2s ease;
}

.dpe-tooltip-trigger:hover .dpe-tooltip-icon {
    color: #374151;
    background: #e5e7eb;
}

/* Tooltip content container */
.dpe-tooltip-content {
    position: absolute;
    z-index: 999999;
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    white-space: normal;
}

/* Show tooltip on hover (default trigger) */
.dpe-tooltip-trigger[data-tooltip-trigger="hover"]:hover .dpe-tooltip-content,
.dpe-tooltip-trigger[data-tooltip-trigger="hover"]:focus .dpe-tooltip-content {
    visibility: visible;
    opacity: 1;
}

/* Show tooltip on click */
.dpe-tooltip-trigger[data-tooltip-trigger="click"].dpe-tooltip-active .dpe-tooltip-content {
    visibility: visible;
    opacity: 1;
}

/* Show tooltip on focus */
.dpe-tooltip-trigger[data-tooltip-trigger="focus"]:focus .dpe-tooltip-content {
    visibility: visible;
    opacity: 1;
}

/* Tooltip inner content */
.dpe-tooltip-inner {
    display: block;
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 14px;
    line-height: 1.5;
    font-weight: normal;
    text-align: left;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15), 0 4px 6px rgba(0, 0, 0, 0.1);
    max-width: var(--tooltip-max-width, 400px);
    min-width: 300px;
}

/* Arrow styles */
.dpe-tooltip-arrow {
    position: absolute;
    width: 0;
    height: 0;
    border-style: solid;
}

/* Position: Top (default) */
.dpe-tooltip-trigger[data-tooltip-position="top"] .dpe-tooltip-content,
.dpe-tooltip-trigger:not([data-tooltip-position]) .dpe-tooltip-content {
    bottom: calc(100% + 8px);
    right: -20px;
    transform: none;
    /* Ensure tooltip doesn't go off-screen */
    max-width: calc(100vw - 20px);
}

.dpe-tooltip-trigger[data-tooltip-position="top"] .dpe-tooltip-arrow,
.dpe-tooltip-trigger:not([data-tooltip-position]) .dpe-tooltip-arrow {
    bottom: -6px;
    right: 25px;
    left: auto;
    transform: none;
    border-width: 6px 6px 0 6px;
}

/* Position: Bottom */
.dpe-tooltip-trigger[data-tooltip-position="bottom"] .dpe-tooltip-content {
    top: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%);
}

.dpe-tooltip-trigger[data-tooltip-position="bottom"] .dpe-tooltip-arrow {
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-width: 0 6px 6px 6px;
}

/* Position: Left */
.dpe-tooltip-trigger[data-tooltip-position="left"] .dpe-tooltip-content {
    right: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%);
}

.dpe-tooltip-trigger[data-tooltip-position="left"] .dpe-tooltip-arrow {
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    border-width: 6px 0 6px 6px;
}

/* Position: Right */
.dpe-tooltip-trigger[data-tooltip-position="right"] .dpe-tooltip-content {
    left: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%);
}

.dpe-tooltip-trigger[data-tooltip-position="right"] .dpe-tooltip-arrow {
    right: 100%;
    top: 50%;
    transform: translateY(-50%);
    border-width: 6px 6px 6px 0;
}

/* Theme: Dark (default) */
.dpe-tooltip-trigger[data-tooltip-theme="dark"] .dpe-tooltip-inner,
.dpe-tooltip-trigger:not([data-tooltip-theme]) .dpe-tooltip-inner {
    background-color: #1f2937;
    color: #ffffff;
}

.dpe-tooltip-trigger[data-tooltip-theme="dark"] .dpe-tooltip-arrow,
.dpe-tooltip-trigger:not([data-tooltip-theme]) .dpe-tooltip-arrow {
    border-top-color: #1f2937;
    border-right-color: transparent;
    border-bottom-color: transparent;
    border-left-color: transparent;
}

.dpe-tooltip-trigger[data-tooltip-position="bottom"][data-tooltip-theme="dark"] .dpe-tooltip-arrow,
.dpe-tooltip-trigger[data-tooltip-position="bottom"]:not([data-tooltip-theme]) .dpe-tooltip-arrow {
    border-top-color: transparent;
    border-bottom-color: #1f2937;
}

.dpe-tooltip-trigger[data-tooltip-position="left"][data-tooltip-theme="dark"] .dpe-tooltip-arrow,
.dpe-tooltip-trigger[data-tooltip-position="left"]:not([data-tooltip-theme]) .dpe-tooltip-arrow {
    border-top-color: transparent;
    border-left-color: #1f2937;
}

.dpe-tooltip-trigger[data-tooltip-position="right"][data-tooltip-theme="dark"] .dpe-tooltip-arrow,
.dpe-tooltip-trigger[data-tooltip-position="right"]:not([data-tooltip-theme]) .dpe-tooltip-arrow {
    border-top-color: transparent;
    border-right-color: #1f2937;
}

/* Theme: Light */
.dpe-tooltip-trigger[data-tooltip-theme="light"] .dpe-tooltip-inner {
    background-color: #ffffff;
    color: #1f2937;
    border: 1px solid #e5e7eb;
}

.dpe-tooltip-trigger[data-tooltip-theme="light"] .dpe-tooltip-arrow {
    border-top-color: #ffffff;
    border-right-color: transparent;
    border-bottom-color: transparent;
    border-left-color: transparent;
}

.dpe-tooltip-trigger[data-tooltip-position="bottom"][data-tooltip-theme="light"] .dpe-tooltip-arrow {
    border-top-color: transparent;
    border-bottom-color: #ffffff;
}

.dpe-tooltip-trigger[data-tooltip-position="left"][data-tooltip-theme="light"] .dpe-tooltip-arrow {
    border-top-color: transparent;
    border-left-color: #ffffff;
}

.dpe-tooltip-trigger[data-tooltip-position="right"][data-tooltip-theme="light"] .dpe-tooltip-arrow {
    border-top-color: transparent;
    border-right-color: #ffffff;
}

/* Theme: Info */
.dpe-tooltip-trigger[data-tooltip-theme="info"] .dpe-tooltip-inner {
    background-color: #3b82f6;
    color: #ffffff;
}

.dpe-tooltip-trigger[data-tooltip-theme="info"] .dpe-tooltip-arrow {
    border-top-color: #3b82f6;
    border-right-color: transparent;
    border-bottom-color: transparent;
    border-left-color: transparent;
}

.dpe-tooltip-trigger[data-tooltip-position="bottom"][data-tooltip-theme="info"] .dpe-tooltip-arrow {
    border-top-color: transparent;
    border-bottom-color: #3b82f6;
}

.dpe-tooltip-trigger[data-tooltip-position="left"][data-tooltip-theme="info"] .dpe-tooltip-arrow {
    border-top-color: transparent;
    border-left-color: #3b82f6;
}

.dpe-tooltip-trigger[data-tooltip-position="right"][data-tooltip-theme="info"] .dpe-tooltip-arrow {
    border-top-color: transparent;
    border-right-color: #3b82f6;
}

/* Theme: Warning */
.dpe-tooltip-trigger[data-tooltip-theme="warning"] .dpe-tooltip-inner {
    background-color: #f59e0b;
    color: #ffffff;
}

.dpe-tooltip-trigger[data-tooltip-theme="warning"] .dpe-tooltip-arrow {
    border-top-color: #f59e0b;
    border-right-color: transparent;
    border-bottom-color: transparent;
    border-left-color: transparent;
}

.dpe-tooltip-trigger[data-tooltip-position="bottom"][data-tooltip-theme="warning"] .dpe-tooltip-arrow {
    border-top-color: transparent;
    border-bottom-color: #f59e0b;
}

.dpe-tooltip-trigger[data-tooltip-position="left"][data-tooltip-theme="warning"] .dpe-tooltip-arrow {
    border-top-color: transparent;
    border-left-color: #f59e0b;
}

.dpe-tooltip-trigger[data-tooltip-position="right"][data-tooltip-theme="warning"] .dpe-tooltip-arrow {
    border-top-color: transparent;
    border-right-color: #f59e0b;
}

/* Theme: Success */
.dpe-tooltip-trigger[data-tooltip-theme="success"] .dpe-tooltip-inner {
    background-color: #10b981;
    color: #ffffff;
}

.dpe-tooltip-trigger[data-tooltip-theme="success"] .dpe-tooltip-arrow {
    border-top-color: #10b981;
    border-right-color: transparent;
    border-bottom-color: transparent;
    border-left-color: transparent;
}

.dpe-tooltip-trigger[data-tooltip-position="bottom"][data-tooltip-theme="success"] .dpe-tooltip-arrow {
    border-top-color: transparent;
    border-bottom-color: #10b981;
}

.dpe-tooltip-trigger[data-tooltip-position="left"][data-tooltip-theme="success"] .dpe-tooltip-arrow {
    border-top-color: transparent;
    border-left-color: #10b981;
}

.dpe-tooltip-trigger[data-tooltip-position="right"][data-tooltip-theme="success"] .dpe-tooltip-arrow {
    border-top-color: transparent;
    border-right-color: #10b981;
}

/* Theme: Light Grey */
.dpe-tooltip-trigger[data-tooltip-theme="light-grey"] .dpe-tooltip-inner {
    background-color: #f3f4f6;
    color: #1f2937;
    border: 1px solid #d1d5db;
}

.dpe-tooltip-trigger[data-tooltip-theme="light-grey"] .dpe-tooltip-arrow {
    border-top-color: #f3f4f6;
    border-right-color: transparent;
    border-bottom-color: transparent;
    border-left-color: transparent;
}

.dpe-tooltip-trigger[data-tooltip-position="bottom"][data-tooltip-theme="light-grey"] .dpe-tooltip-arrow {
    border-top-color: transparent;
    border-bottom-color: #f3f4f6;
}

.dpe-tooltip-trigger[data-tooltip-position="left"][data-tooltip-theme="light-grey"] .dpe-tooltip-arrow {
    border-top-color: transparent;
    border-left-color: #f3f4f6;
}

.dpe-tooltip-trigger[data-tooltip-position="right"][data-tooltip-theme="light-grey"] .dpe-tooltip-arrow {
    border-top-color: transparent;
    border-right-color: #f3f4f6;
}

/* Mobile responsive adjustments */
@media (max-width: 768px) {
    .dpe-tooltip-inner {
        max-width: min(350px, 90vw);
        font-size: 13px;
    }
    
    /* Force top position on mobile to avoid viewport issues */
    .dpe-tooltip-content {
        bottom: calc(100% + 8px) !important;
        left: 10px !important;
        right: 10px !important;
        top: auto !important;
        transform: none !important;
        max-width: calc(100vw - 20px) !important;
    }
    
    .dpe-tooltip-arrow {
        bottom: -6px !important;
        left: auto !important;
        right: 15px !important;
        top: auto !important;
        transform: none !important;
        border-width: 6px 6px 0 6px !important;
        border-top-color: inherit;
        border-right-color: transparent !important;
        border-bottom-color: transparent !important;
        border-left-color: transparent !important;
    }
}

/* Accessibility improvements */
.dpe-tooltip-trigger:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* Animation for smooth appearance */
@keyframes dpe-tooltip-fade-in {
    from {
        opacity: 0;
        transform: translateY(4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dpe-tooltip-content {
    animation: dpe-tooltip-fade-in 0.3s ease forwards;
}