/* ===================================
   MORE INFO PLUGIN STYLES
   =================================== */

/* Base Trigger Styles */
[data-cb-type="more-info"] {
    position: relative;
    cursor: help;
    transition: all 0.2s ease;
    white-space: nowrap;
    -webkit-user-select: none;
    user-select: none;
}

[data-cb-type="more-info"]:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
    border-radius: 2px;
}

/* ===================================
   STYLE VARIANTS
   =================================== */

/* 🛈 INFO STYLE (Blue) */
[data-cb-type="more-info"].style-info {
    color: #2563eb;
    border-bottom: 1px dotted #2563eb;
    font-weight: 500;
}

[data-cb-type="more-info"].style-info::after {
    content: "ⓘ";
    display: inline-block;
    font-size: 0.85em;
    margin-left: 2px;
    opacity: 0.7;
    font-style: normal;
}

[data-cb-type="more-info"].style-info:hover {
    color: #1d4ed8;
    border-bottom-color: #1d4ed8;
}

/* [#] CITATION STYLE (Superscript) */
[data-cb-type="more-info"].style-citation {
    color: #059669;
    font-weight: 500;
    position: relative;

    font-size: 0.8em;
    vertical-align: super;
    text-decoration: none;
}

[data-cb-type="more-info"].style-citation::before {
    content: "[";
    font-weight: 600;
}

[data-cb-type="more-info"].style-citation::after {
    content: "]";
    font-weight: 600;
}

[data-cb-type="more-info"].style-citation:hover {
    color: #047857;
    text-decoration: underline;
}

/* Counter for auto-numbering citations */
body {
    counter-reset: citation-counter;
}

[data-cb-type="more-info"].style-citation {
    counter-increment: citation-counter;
}

[data-cb-type="more-info"].style-citation.use-counter::before {
    content: "[" counter(citation-counter);
}

[data-cb-type="more-info"].style-citation.use-counter::after {
    content: "]";
}

/* ✨ HIGHLIGHT STYLE (Yellow) */
[data-cb-type="more-info"].style-highlight {
    background: linear-gradient(180deg, transparent 60%, #fef08a 60%);
    color: #854d0e;
    padding: 2px 4px;
    border-radius: 2px;
    font-weight: 500;
    position: relative;
}

[data-cb-type="more-info"].style-highlight::before {
    content: "✨";
    font-size: 0.75em;
    margin-right: 2px;
    opacity: 0.8;
}

[data-cb-type="more-info"].style-highlight:hover {
    background: linear-gradient(180deg, transparent 60%, #fde047 60%);
    color: #713f12;
}

/* ===================================
   POPOVER STYLES
   =================================== */

.more-info-popover {
    position: absolute;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
    pointer-events: none;
}

.more-info-popover.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
}

.more-info-popover.position-bottom {
    transform: translateY(4px);
}

.more-info-popover.position-bottom.visible {
    transform: translateY(0);
}

/* Popover Content Box */
.popover-content {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 14px 16px;
    box-shadow: 
        0 4px 6px -1px rgba(0, 0, 0, 0.1),
        0 2px 4px -1px rgba(0, 0, 0, 0.06),
        0 0 0 1px rgba(0, 0, 0, 0.05);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: #374151;
    max-height: 400px;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Popover Arrow */
.popover-arrow {
    position: absolute;
    width: 12px;
    height: 12px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    transform: rotate(45deg);
    z-index: -1;
}

.more-info-popover.position-top .popover-arrow {
    bottom: -7px;
    border-top: none;
    border-left: none;
}

.more-info-popover.position-bottom .popover-arrow {
    top: -7px;
    border-bottom: none;
    border-right: none;
}

/* ===================================
   POPOVER CONTENT FORMATTING
   =================================== */

.popover-content p {
    margin: 0 0 10px 0;
}

.popover-content p:last-child {
    margin-bottom: 0;
}

.popover-content strong,
.popover-content b {
    font-weight: 600;
    color: #111827;
}

.popover-content em,
.popover-content i {
    font-style: italic;
}

.popover-content a {
    color: #2563eb;
    text-decoration: underline;
    transition: color 0.2s;
}

.popover-content a:hover {
    color: #1d4ed8;
}

.popover-content ul,
.popover-content ol {
    margin: 8px 0;
    padding-left: 24px;
}

.popover-content li {
    margin: 4px 0;
}

.popover-content code {
    background: #f3f4f6;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 0.9em;
    color: #dc2626;
}

.popover-content hr {
    border: none;
    border-top: 1px solid #e5e7eb;
    margin: 12px 0;
}

/* Custom scrollbar for popover */
.popover-content::-webkit-scrollbar {
    width: 6px;
}

.popover-content::-webkit-scrollbar-track {
    background: #f3f4f6;
    border-radius: 3px;
}

.popover-content::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

.popover-content::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* ===================================
   DARK MODE SUPPORT
   =================================== */

[data-cb-skin="dark"] [data-cb-type="more-info"].style-info {
    color: #60a5fa;
    border-bottom-color: #60a5fa;
}

[data-cb-skin="dark"] [data-cb-type="more-info"].style-info:hover {
    color: #93c5fd;
    border-bottom-color: #93c5fd;
}

[data-cb-skin="dark"] [data-cb-type="more-info"].style-citation {
    color: #34d399;
}

[data-cb-skin="dark"] [data-cb-type="more-info"].style-citation:hover {
    color: #6ee7b7;
}

[data-cb-skin="dark"] [data-cb-type="more-info"].style-highlight {
    background: linear-gradient(180deg, transparent 60%, #854d0e 60%);
    color: #fef08a;
}

[data-cb-skin="dark"] [data-cb-type="more-info"].style-highlight:hover {
    background: linear-gradient(180deg, transparent 60%, #a16207 60%);
    color: #fde047;
}

[data-cb-skin="dark"] .popover-content {
    background: #1f2937;
    border-color: #374151;
    color: #d1d5db;
    box-shadow: 
        0 4px 6px -1px rgba(0, 0, 0, 0.3),
        0 2px 4px -1px rgba(0, 0, 0, 0.2),
        0 0 0 1px rgba(0, 0, 0, 0.2);
}

[data-cb-skin="dark"] .popover-arrow {
    background: #1f2937;
    border-color: #374151;
}

[data-cb-skin="dark"] .popover-content strong,
[data-cb-skin="dark"] .popover-content b {
    color: #f9fafb;
}

[data-cb-skin="dark"] .popover-content a {
    color: #60a5fa;
}

[data-cb-skin="dark"] .popover-content a:hover {
    color: #93c5fd;
}

[data-cb-skin="dark"] .popover-content code {
    background: #374151;
    color: #fca5a5;
}

[data-cb-skin="dark"] .popover-content hr {
    border-top-color: #374151;
}

[data-cb-skin="dark"] .popover-content::-webkit-scrollbar-track {
    background: #374151;
}

[data-cb-skin="dark"] .popover-content::-webkit-scrollbar-thumb {
    background: #4b5563;
}

[data-cb-skin="dark"] .popover-content::-webkit-scrollbar-thumb:hover {
    background: #6b7280;
}

/* ===================================
   RESPONSIVE BEHAVIOR
   =================================== */

@media (max-width: 768px) {
    .more-info-popover {
        max-width: calc(100vw - 40px) !important;
    }

    .popover-content {
        font-size: 13px;
        padding: 12px 14px;
        max-height: 300px;
    }

    /* Larger touch targets on mobile */
    [data-cb-type="more-info"] {
        padding: 4px;
        margin: -4px;
    }
}

@media (max-width: 480px) {
    .more-info-popover {
        max-width: calc(100vw - 24px) !important;
    }

    .popover-content {
        font-size: 12px;
        padding: 10px 12px;
    }
}

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

/* High contrast mode support */
@media (prefers-contrast: high) {
    [data-cb-type="more-info"] {
        text-decoration: underline;
        text-decoration-style: dotted;
    }

    .popover-content {
        border-width: 2px;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    [data-cb-type="more-info"],
    .more-info-popover,
    .popover-content a {
        transition: none;
    }
}

/* Focus visible for keyboard navigation */
[data-cb-type="more-info"]:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
    border-radius: 2px;
}

/* Print styles - show content inline */
@media print {
    [data-cb-type="more-info"]::after {
        content: " (" attr(data-cb-content) ")";
        font-size: 0.9em;
        color: #666;
    }

    .more-info-popover {
        display: none;
    }
}