/**
 * Dictation Hints Styles for somaNotes
 *
 * ARCHITECTURE: Subtle inline hint styling for voice dictation
 * WHY: Help users catch ambiguities without being intrusive
 * NOTE: Integrates with existing CSS custom properties
 */

/* ===========================================================================
   HINT MARKERS (inline in transcript)
   =========================================================================== */

.hint-marker {
    position: relative;
    cursor: help;
    border-radius: 2px;
    padding: 0 2px;
    transition: background-color 0.2s;
}

.hint-marker:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

/* Type-specific styling */
.hint-pronoun {
    border-bottom: 2px dotted var(--hint-amber, #f59e0b);
}

.hint-negation {
    border-bottom: 2px dotted var(--hint-green, #10b981);
}

.hint-uncertain {
    text-decoration: wavy underline var(--hint-yellow, #eab308);
    text-decoration-skip-ink: none;
    text-underline-offset: 2px;
}

.hint-unit {
    background: rgba(59, 130, 246, 0.1);
    border: 1px dashed var(--hint-blue, #3b82f6);
    border-radius: 3px;
}

.hint-temporal {
    border-bottom: 2px dotted var(--hint-purple, #8b5cf6);
}

/* ===========================================================================
   PHASE 6: CLINICAL SAFETY HINTS
   Higher visibility styles for safety-critical alerts
   =========================================================================== */

/* Critical lab values - red with solid underline */
.hint-critical-lab {
    background: rgba(239, 68, 68, 0.15);
    border-bottom: 3px solid var(--hint-critical, #ef4444);
    font-weight: 600;
}

.hint-critical-lab.severity-critical {
    background: rgba(239, 68, 68, 0.25);
    animation: hint-pulse-critical 2s ease-in-out infinite;
}

.hint-critical-lab.severity-warning {
    background: rgba(245, 158, 11, 0.15);
    border-bottom-color: var(--hint-amber, #f59e0b);
}

/* Drug interactions - orange with double underline */
.hint-drug-interaction {
    background: rgba(249, 115, 22, 0.15);
    border-bottom: 3px double var(--hint-interaction, #f97316);
    font-weight: 600;
}

.hint-drug-interaction.severity-critical {
    background: rgba(239, 68, 68, 0.20);
    border-bottom-color: var(--hint-critical, #ef4444);
    animation: hint-pulse-critical 2s ease-in-out infinite;
}

/* Contraindication alerts - red outline */
.hint-contraindication {
    background: rgba(239, 68, 68, 0.10);
    border: 2px solid var(--hint-critical, #ef4444);
    border-radius: 4px;
    padding: 1px 4px;
}

.hint-contraindication.severity-critical {
    background: rgba(239, 68, 68, 0.25);
    border-width: 3px;
    animation: hint-pulse-critical 2s ease-in-out infinite;
}

/* Allergy mentions - magenta with strikethrough effect */
.hint-allergy-mention {
    background: rgba(236, 72, 153, 0.20);
    border: 2px solid var(--hint-allergy, #ec4899);
    border-radius: 4px;
    padding: 1px 4px;
    position: relative;
}

.hint-allergy-mention::before {
    content: '⚠';
    position: absolute;
    left: -16px;
    font-size: 12px;
    color: var(--hint-allergy, #ec4899);
}

/* Safety hint badges with distinct colors */
.hint-badge.badge-critical-lab {
    background: var(--hint-critical, #ef4444);
}

.hint-badge.badge-drug-interaction {
    background: var(--hint-interaction, #f97316);
}

.hint-badge.badge-contraindication {
    background: var(--hint-critical, #ef4444);
}

.hint-badge.badge-allergy-mention {
    background: var(--hint-allergy, #ec4899);
}

/* Pulse animation for critical alerts */
@keyframes hint-pulse-critical {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
    }
    50% {
        box-shadow: 0 0 0 4px rgba(239, 68, 68, 0);
    }
}

/* Safety hint tooltip header colors */
.tooltip-icon.icon-critical-lab {
    background: var(--hint-critical, #ef4444);
}

.tooltip-icon.icon-drug-interaction {
    background: var(--hint-interaction, #f97316);
}

.tooltip-icon.icon-contraindication {
    background: var(--hint-critical, #ef4444);
}

.tooltip-icon.icon-allergy-mention {
    background: var(--hint-allergy, #ec4899);
}

/* Safety hint CSS custom properties */
:root {
    --hint-critical: #ef4444;
    --hint-interaction: #f97316;
    --hint-allergy: #ec4899;
    --hint-warning-bg: rgba(245, 158, 11, 0.15);
    --hint-critical-bg: rgba(239, 68, 68, 0.15);
}

/* Dark mode adjustments for safety hints */
@media (prefers-color-scheme: dark) {
    .hint-critical-lab,
    .hint-drug-interaction,
    .hint-contraindication,
    .hint-allergy-mention {
        /* Slightly brighter backgrounds in dark mode */
    }

    .hint-critical-lab.severity-critical,
    .hint-drug-interaction.severity-critical,
    .hint-contraindication.severity-critical {
        background: rgba(239, 68, 68, 0.30);
    }
}

/* High contrast mode for safety hints */
@media (prefers-contrast: high) {
    .hint-critical-lab {
        border-bottom-width: 4px;
        font-weight: 700;
    }

    .hint-drug-interaction {
        border-bottom-width: 4px;
    }

    .hint-contraindication {
        border-width: 3px;
    }

    .hint-allergy-mention {
        border-width: 3px;
    }
}

/* Hint Badge (small icon after marked text) */
.hint-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    font-size: 10px;
    font-weight: bold;
    color: white;
    border-radius: 3px;
    margin-left: 2px;
    vertical-align: super;
    line-height: 1;
    opacity: 0.9;
    transition: opacity 0.2s, transform 0.2s;
}

.hint-marker:hover .hint-badge {
    opacity: 1;
    transform: scale(1.1);
}

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

.hint-tooltip {
    position: fixed;
    z-index: 10000;
    background: var(--bg-elevated, #1f2937);
    border: 1px solid var(--border, #374151);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    max-width: 240px;
    font-size: 13px;
    animation: hint-tooltip-appear 0.2s ease-out;
}

@keyframes hint-tooltip-appear {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.tooltip-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border, #374151);
}

.tooltip-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    font-size: 12px;
    color: white;
    border-radius: 4px;
}

.tooltip-label {
    font-weight: 600;
    color: var(--text, #f9fafb);
}

.tooltip-body {
    padding: 8px 12px;
    color: var(--text-muted, #9ca3af);
    line-height: 1.4;
}

.tooltip-footer {
    padding: 6px 12px;
    border-top: 1px solid var(--border, #374151);
    text-align: right;
}

.tooltip-dismiss {
    background: transparent;
    border: 1px solid var(--border, #374151);
    color: var(--text-muted, #9ca3af);
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: background-color 0.2s, color 0.2s;
}

.tooltip-dismiss:hover {
    background: var(--bg-hover, #374151);
    color: var(--text, #f9fafb);
}

/* ===========================================================================
   SETTINGS PANEL
   =========================================================================== */

.hint-settings-panel {
    position: fixed;
    bottom: 80px;
    right: 20px;
    z-index: 9999;
    background: var(--bg-elevated, #1f2937);
    border: 1px solid var(--border, #374151);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    width: 280px;
    max-height: 400px;
    overflow: hidden;
    animation: hint-panel-appear 0.2s ease-out;
}

@keyframes hint-panel-appear {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.hint-settings-panel.hidden {
    display: none;
}

.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border, #374151);
    font-weight: 600;
    color: var(--text, #f9fafb);
}

.settings-close {
    background: transparent;
    border: none;
    color: var(--text-muted, #9ca3af);
    font-size: 20px;
    cursor: pointer;
    line-height: 1;
    padding: 4px;
    border-radius: 4px;
    transition: background-color 0.2s, color 0.2s;
}

.settings-close:hover {
    background: var(--bg-hover, #374151);
    color: var(--text, #f9fafb);
}

.settings-body {
    padding: 8px 0;
    max-height: 320px;
    overflow-y: auto;
}

.setting-item {
    display: grid;
    grid-template-columns: auto auto 1fr;
    grid-template-rows: auto auto;
    gap: 4px 8px;
    align-items: center;
    padding: 10px 16px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.setting-item:hover {
    background: var(--bg-hover, #374151);
}

.setting-item input[type="checkbox"] {
    grid-row: span 2;
    width: 16px;
    height: 16px;
    accent-color: var(--primary, #3b82f6);
}

.setting-icon {
    grid-row: span 2;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    font-size: 12px;
    color: white;
    border-radius: 4px;
}

.setting-label {
    font-weight: 500;
    color: var(--text, #f9fafb);
}

.setting-desc {
    grid-column: 3;
    font-size: 11px;
    color: var(--text-muted, #9ca3af);
}

/* ===========================================================================
   HINT COUNT BADGE
   =========================================================================== */

#hint-count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    font-size: 11px;
    font-weight: bold;
    color: white;
    background: var(--hint-amber, #f59e0b);
    border-radius: 9px;
    padding: 0 5px;
    margin-left: 6px;
}

#hint-count-badge.hidden {
    display: none;
}

/* ===========================================================================
   HINT SETTINGS BUTTON (in dictation toolbar)
   =========================================================================== */

.hint-settings-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: transparent;
    border: 1px solid var(--border, #374151);
    border-radius: 6px;
    color: var(--text-muted, #9ca3af);
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}

.hint-settings-btn:hover {
    background: var(--bg-hover, #374151);
    color: var(--text, #f9fafb);
    border-color: var(--border-hover, #4b5563);
}

.hint-settings-btn.active {
    background: var(--primary-soft, rgba(59, 130, 246, 0.2));
    color: var(--primary, #3b82f6);
    border-color: var(--primary, #3b82f6);
}

/* ===========================================================================
   DARK MODE ADJUSTMENTS
   =========================================================================== */

@media (prefers-color-scheme: dark) {
    .hint-marker:hover {
        background-color: rgba(255, 255, 255, 0.1);
    }

    .hint-unit {
        background: rgba(59, 130, 246, 0.15);
    }
}

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

/* Focus states for keyboard navigation */
.hint-marker:focus {
    outline: 2px solid var(--primary, #3b82f6);
    outline-offset: 2px;
}

.hint-settings-btn:focus {
    outline: 2px solid var(--primary, #3b82f6);
    outline-offset: 2px;
}

.setting-item input:focus {
    outline: 2px solid var(--primary, #3b82f6);
    outline-offset: 2px;
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    .hint-marker,
    .hint-badge,
    .hint-tooltip,
    .hint-settings-panel,
    .tooltip-dismiss,
    .settings-close,
    .setting-item {
        transition: none;
    }

    @keyframes hint-tooltip-appear {
        from { opacity: 1; }
        to { opacity: 1; }
    }

    @keyframes hint-panel-appear {
        from { opacity: 1; }
        to { opacity: 1; }
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .hint-pronoun {
        border-bottom-width: 3px;
    }

    .hint-negation {
        border-bottom-width: 3px;
    }

    .hint-uncertain {
        text-decoration-thickness: 3px;
    }

    .hint-unit {
        border-width: 2px;
    }

    .hint-temporal {
        border-bottom-width: 3px;
    }
}
