/**
 * ============================================================================
 * PharmAssist Tooltip Styles
 * ============================================================================
 * Location: public_html/styles/tooltips.css
 * 
 * Features:
 * - Dark/light theme support using CSS variables
 * - Smooth animations
 * - Positioned arrows
 * - Keyboard focus styles
 * - Responsive sizing
 * 
 * @version 1.0.0
 * @created February 2026
 * ============================================================================
 */

/* ============================================================================
   CSS VARIABLES
   ============================================================================ */

:root {
    --tooltip-bg: #1a1a1a;
    --tooltip-text: #ffffff;
    --tooltip-border: #2a2a2a;
    --tooltip-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    --tooltip-max-width: 300px;
    --tooltip-z-index: 10000;
}

body.light-mode {
    --tooltip-bg: #1e293b;
    --tooltip-text: #ffffff;
    --tooltip-border: #334155;
    --tooltip-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* ============================================================================
   TOOLTIP TRIGGER
   ============================================================================ */

.tooltip-trigger {
    cursor: help;
    position: relative;
}

.tooltip-trigger:focus {
    outline: 2px solid #00d4ff;
    outline-offset: 2px;
    border-radius: 4px;
}

/* ============================================================================
   HELP ICON
   ============================================================================ */

.help-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: linear-gradient(135deg, #00d4ff 0%, #7c3aed 100%);
    color: #ffffff;
    font-size: 12px;
    font-weight: bold;
    cursor: help;
    margin-left: 6px;
    vertical-align: middle;
    transition: all 0.2s ease;
    user-select: none;
}

.help-icon:hover {
    transform: scale(1.1);
    box-shadow: 0 0 12px rgba(0, 212, 255, 0.4);
}

.help-icon:focus {
    outline: 2px solid #00d4ff;
    outline-offset: 2px;
}

body.light-mode .help-icon {
    background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
}

/* ============================================================================
   TOOLTIP CONTAINER
   ============================================================================ */

.tooltip {
    position: absolute;
    max-width: var(--tooltip-max-width);
    padding: 12px 16px;
    background: var(--tooltip-bg);
    color: var(--tooltip-text);
    border: 1px solid var(--tooltip-border);
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.5;
    box-shadow: var(--tooltip-shadow);
    z-index: var(--tooltip-z-index);
    pointer-events: none;
    opacity: 0;
    transform: translateY(-5px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.tooltip-visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* Tooltip content formatting */
.tooltip strong {
    color: #00d4ff;
    display: block;
    margin-bottom: 6px;
}

body.light-mode .tooltip strong {
    color: #3b82f6;
}

.tooltip em {
    color: #a0a0a0;
    font-style: italic;
}

body.light-mode .tooltip em {
    color: #cbd5e1;
}

.tooltip ul,
.tooltip ol {
    margin: 8px 0;
    padding-left: 20px;
}

.tooltip li {
    margin: 4px 0;
}

/* ============================================================================
   TOOLTIP ARROW
   ============================================================================ */

.tooltip-arrow {
    position: absolute;
    width: 10px;
    height: 10px;
    background: var(--tooltip-bg);
    border: 1px solid var(--tooltip-border);
    transform: rotate(45deg);
    pointer-events: none;
}

/* Arrow positioning based on tooltip position */
.tooltip[data-position="top"] .tooltip-arrow {
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%) rotate(45deg);
    border-top: none;
    border-left: none;
}

.tooltip[data-position="bottom"] .tooltip-arrow {
    top: -6px;
    left: 50%;
    transform: translateX(-50%) rotate(45deg);
    border-bottom: none;
    border-right: none;
}

.tooltip[data-position="left"] .tooltip-arrow {
    right: -6px;
    top: 50%;
    transform: translateY(-50%) rotate(45deg);
    border-left: none;
    border-bottom: none;
}

.tooltip[data-position="right"] .tooltip-arrow {
    left: -6px;
    top: 50%;
    transform: translateY(-50%) rotate(45deg);
    border-right: none;
    border-top: none;
}

/* ============================================================================
   TOOLTIP VARIATIONS
   ============================================================================ */

/* Info tooltip */
.tooltip.tooltip-info {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border-color: #3b82f6;
}

.tooltip.tooltip-info strong {
    color: #60a5fa;
}

/* Warning tooltip */
.tooltip.tooltip-warning {
    background: linear-gradient(135deg, #2e1a1a 0%, #3e1616 100%);
    border-color: #f59e0b;
}

.tooltip.tooltip-warning strong {
    color: #fbbf24;
}

/* Success tooltip */
.tooltip.tooltip-success {
    background: linear-gradient(135deg, #1a2e1a 0%, #163e16 100%);
    border-color: #10b981;
}

.tooltip.tooltip-success strong {
    color: #34d399;
}

/* Error tooltip */
.tooltip.tooltip-error {
    background: linear-gradient(135deg, #2e1a1a 0%, #3e1616 100%);
    border-color: #ef4444;
}

.tooltip.tooltip-error strong {
    color: #f87171;
}

/* ============================================================================
   RESPONSIVE ADJUSTMENTS
   ============================================================================ */

@media (max-width: 768px) {
    .tooltip {
        max-width: 250px;
        font-size: 12px;
        padding: 10px 14px;
    }

    .help-icon {
        width: 16px;
        height: 16px;
        font-size: 11px;
    }
}

@media (max-width: 480px) {
    .tooltip {
        max-width: calc(100vw - 40px);
    }
}

/* ============================================================================
   ANIMATIONS
   ============================================================================ */

@keyframes tooltip-fade-in {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes tooltip-fade-out {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-5px);
    }
}

/* ============================================================================
   ACCESSIBILITY
   ============================================================================ */

/* High contrast mode */
@media (prefers-contrast: high) {
    .tooltip {
        border-width: 2px;
    }

    .help-icon {
        border: 2px solid currentColor;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .tooltip {
        transition: none;
    }

    .help-icon {
        transition: none;
    }
}

/* Print styles */
@media print {
    .tooltip,
    .help-icon {
        display: none !important;
    }
}
