/* Tooltip Component - Cacao UI Framework */

.tooltip-wrapper {
    position: relative;
    display: inline-block;
}

.tooltip {
    position: absolute;
    background-color: #333;
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
    pointer-events: none;
    max-width: 200px;
    word-wrap: break-word;
    line-height: 1.4;
}

.tooltip.visible {
    opacity: 1;
    visibility: visible;
}

/* Tooltip Arrow */
.tooltip::before {
    content: '';
    position: absolute;
    width: 0;
    height: 0;
    border: 5px solid transparent;
}

/* Tooltip Positions */
.tooltip.top {
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 8px;
}

.tooltip.top::before {
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-top-color: #333;
}

.tooltip.bottom {
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 8px;
}

.tooltip.bottom::before {
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-bottom-color: #333;
}

.tooltip.left {
    right: 100%;
    top: 50%;
    transform: translateY(-50%);
    margin-right: 8px;
}

.tooltip.left::before {
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    border-left-color: #333;
}

.tooltip.right {
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    margin-left: 8px;
}

.tooltip.right::before {
    right: 100%;
    top: 50%;
    transform: translateY(-50%);
    border-right-color: #333;
}

/* Tooltip Variants */
.tooltip.light {
    background-color: #fff;
    color: #333;
    border: 1px solid #e8e8e8;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.tooltip.light.top::before {
    border-top-color: #e8e8e8;
    border-top-width: 6px;
}

.tooltip.light.top::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border: 5px solid transparent;
    border-top-color: #fff;
    margin-top: -1px;
}

.tooltip.light.bottom::before {
    border-bottom-color: #e8e8e8;
    border-bottom-width: 6px;
}

.tooltip.light.bottom::after {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border: 5px solid transparent;
    border-bottom-color: #fff;
    margin-bottom: -1px;
}

.tooltip.light.left::before {
    border-left-color: #e8e8e8;
    border-left-width: 6px;
}

.tooltip.light.left::after {
    content: '';
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border: 5px solid transparent;
    border-left-color: #fff;
    margin-left: -1px;
}

.tooltip.light.right::before {
    border-right-color: #e8e8e8;
    border-right-width: 6px;
}

.tooltip.light.right::after {
    content: '';
    position: absolute;
    right: 100%;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border: 5px solid transparent;
    border-right-color: #fff;
    margin-right: -1px;
}

.tooltip.primary {
    background-color: #8B4513;
}

.tooltip.primary.top::before {
    border-top-color: #8B4513;
}

.tooltip.primary.bottom::before {
    border-bottom-color: #8B4513;
}

.tooltip.primary.left::before {
    border-left-color: #8B4513;
}

.tooltip.primary.right::before {
    border-right-color: #8B4513;
}

.tooltip.success {
    background-color: #52c41a;
}

.tooltip.success.top::before {
    border-top-color: #52c41a;
}

.tooltip.success.bottom::before {
    border-bottom-color: #52c41a;
}

.tooltip.success.left::before {
    border-left-color: #52c41a;
}

.tooltip.success.right::before {
    border-right-color: #52c41a;
}

.tooltip.warning {
    background-color: #faad14;
}

.tooltip.warning.top::before {
    border-top-color: #faad14;
}

.tooltip.warning.bottom::before {
    border-bottom-color: #faad14;
}

.tooltip.warning.left::before {
    border-left-color: #faad14;
}

.tooltip.warning.right::before {
    border-right-color: #faad14;
}

.tooltip.error {
    background-color: #ff4d4f;
}

.tooltip.error.top::before {
    border-top-color: #ff4d4f;
}

.tooltip.error.bottom::before {
    border-bottom-color: #ff4d4f;
}

.tooltip.error.left::before {
    border-left-color: #ff4d4f;
}

.tooltip.error.right::before {
    border-right-color: #ff4d4f;
}

/* Tooltip Sizes */
.tooltip.small {
    padding: 4px 8px;
    font-size: 10px;
}

.tooltip.small::before {
    border-width: 4px;
}

.tooltip.large {
    padding: 12px 16px;
    font-size: 14px;
    max-width: 300px;
}

.tooltip.large::before {
    border-width: 6px;
}

/* Tooltip Multiline */
.tooltip.multiline {
    white-space: normal;
    max-width: 200px;
    text-align: left;
}

.tooltip.multiline.small {
    max-width: 150px;
}

.tooltip.multiline.large {
    max-width: 300px;
}

/* Tooltip Animation */
.tooltip-fade-enter {
    opacity: 0;
    transform: scale(0.8);
}

.tooltip-fade-enter-active {
    opacity: 1;
    transform: scale(1);
    transition: all 0.2s ease;
}

.tooltip-fade-exit {
    opacity: 1;
    transform: scale(1);
}

.tooltip-fade-exit-active {
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.2s ease;
}

/* Tooltip Trigger States */
.tooltip-trigger {
    cursor: help;
}

.tooltip-trigger:hover {
    text-decoration: underline;
    text-decoration-style: dotted;
}

.tooltip-trigger.disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

/* Tooltip Content */
.tooltip-title {
    font-weight: 600;
    margin-bottom: 4px;
}

.tooltip-description {
    font-weight: normal;
    opacity: 0.9;
}

/* Tooltip Icon */
.tooltip-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    margin-right: 4px;
    font-size: 12px;
}

/* Tooltip Delay */
.tooltip.delay-short {
    transition-delay: 0.1s;
}

.tooltip.delay-medium {
    transition-delay: 0.5s;
}

.tooltip.delay-long {
    transition-delay: 1s;
}

/* Tooltip Auto-adjust */
.tooltip.auto-adjust {
    max-width: none;
    width: auto;
    min-width: 50px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .tooltip {
        font-size: 11px;
        padding: 6px 10px;
        max-width: 180px;
    }
    
    .tooltip.small {
        font-size: 9px;
        padding: 3px 6px;
    }
    
    .tooltip.large {
        font-size: 12px;
        padding: 8px 12px;
        max-width: 250px;
    }
    
    .tooltip.multiline {
        max-width: 180px;
    }
    
    .tooltip.multiline.small {
        max-width: 130px;
    }
    
    .tooltip.multiline.large {
        max-width: 250px;
    }
}

/* Accessibility */
.tooltip[role="tooltip"] {
    pointer-events: none;
}

.tooltip-wrapper:focus .tooltip {
    opacity: 1;
    visibility: visible;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .tooltip {
        background-color: #000;
        color: #fff;
        border: 2px solid #fff;
    }
    
    .tooltip.light {
        background-color: #fff;
        color: #000;
        border: 2px solid #000;
    }
    
    .tooltip::before {
        border-color: transparent;
    }
    
    .tooltip.top::before {
        border-top-color: #000;
    }
    
    .tooltip.bottom::before {
        border-bottom-color: #000;
    }
    
    .tooltip.left::before {
        border-left-color: #000;
    }
    
    .tooltip.right::before {
        border-right-color: #000;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .tooltip {
        transition: none;
    }
    
    .tooltip-fade-enter-active,
    .tooltip-fade-exit-active {
        transition: none;
    }
}

/* Print Styles */
@media print {
    .tooltip {
        position: static;
        opacity: 1;
        visibility: visible;
        background-color: transparent;
        color: #000;
        border: 1px solid #000;
        padding: 4px;
        margin: 2px 0;
        font-size: 10px;
    }
    
    .tooltip::before {
        display: none;
    }
    
    .tooltip-wrapper::after {
        content: " [" attr(title) "]";
        font-size: 10px;
        color: #666;
    }
}