/* AutoPilot Internal Linking Frontend Styles */

/* Internal Links Generated by AutoPilot */
.autopilot-internal-link {
    color: #0073aa;
    text-decoration: underline;
    transition: color 0.2s ease;
    position: relative;
}

.autopilot-internal-link:hover {
    color: #005a87;
    text-decoration: none;
}

.autopilot-internal-link:visited {
    color: #551a8b;
}

/* High confidence links styling */
.autopilot-internal-link[data-confidence*="0.9"],
.autopilot-internal-link[data-confidence*="1.0"] {
    font-weight: 500;
    border-bottom: 2px solid #0073aa;
    text-decoration: none;
}

.autopilot-internal-link[data-confidence*="0.9"]:hover,
.autopilot-internal-link[data-confidence*="1.0"]:hover {
    border-bottom-color: #005a87;
}

/* Medium confidence links styling */
.autopilot-internal-link[data-confidence*="0.7"],
.autopilot-internal-link[data-confidence*="0.8"] {
    border-bottom: 1px dotted #0073aa;
    text-decoration: none;
}

/* Low confidence links styling */
.autopilot-internal-link[data-confidence*="0.5"],
.autopilot-internal-link[data-confidence*="0.6"] {
    opacity: 0.8;
}

/* Link preview tooltip */
.autopilot-internal-link::after {
    content: attr(data-preview);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    z-index: 1000;
    max-width: 200px;
    white-space: normal;
    width: max-content;
}

.autopilot-internal-link:hover::after {
    opacity: 1;
    visibility: visible;
}

/* Tooltip arrow */
.autopilot-internal-link::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-width: 5px;
    border-style: solid;
    border-color: #333 transparent transparent transparent;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.autopilot-internal-link:hover::before {
    opacity: 1;
    visibility: visible;
}

/* Link categories styling */
.autopilot-internal-link[data-category="educational"] {
    color: #28a745;
}

.autopilot-internal-link[data-category="educational"]:hover {
    color: #1e7e34;
}

.autopilot-internal-link[data-category="commercial"] {
    color: #ffc107;
}

.autopilot-internal-link[data-category="commercial"]:hover {
    color: #e0a800;
}

.autopilot-internal-link[data-category="news"] {
    color: #dc3545;
}

.autopilot-internal-link[data-category="news"]:hover {
    color: #c82333;
}

/* Link animation for newly added links */
.autopilot-internal-link.newly-added {
    animation: linkHighlight 2s ease-in-out;
}

@keyframes linkHighlight {
    0% {
        background-color: #fff3cd;
        padding: 2px 4px;
        border-radius: 3px;
    }
    100% {
        background-color: transparent;
        padding: 0;
    }
}

/* Loading state for links being processed */
.autopilot-link-processing {
    position: relative;
    opacity: 0.7;
}

.autopilot-link-processing::after {
    content: '';
    position: absolute;
    top: 50%;
    right: -20px;
    width: 12px;
    height: 12px;
    border: 2px solid #ddd;
    border-top: 2px solid #0073aa;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Related posts suggestions */
.autopilot-related-posts {
    margin: 30px 0;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid #0073aa;
}

.autopilot-related-posts h3 {
    margin-top: 0;
    color: #333;
    font-size: 18px;
    margin-bottom: 15px;
}

.autopilot-related-posts ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.autopilot-related-posts li {
    margin-bottom: 10px;
    padding: 10px;
    background: white;
    border-radius: 4px;
    border: 1px solid #ddd;
    transition: transform 0.2s ease;
}

.autopilot-related-posts li:hover {
    transform: translateX(5px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.autopilot-related-posts a {
    color: #0073aa;
    text-decoration: none;
    font-weight: 500;
    display: block;
    margin-bottom: 5px;
}

.autopilot-related-posts a:hover {
    color: #005a87;
}

.autopilot-related-posts .post-excerpt {
    color: #666;
    font-size: 14px;
    line-height: 1.4;
}

/* SEO score indicator */
.autopilot-seo-score {
    display: inline-block;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    color: white;
    font-weight: bold;
    font-size: 12px;
    text-align: center;
    line-height: 30px;
    margin-right: 10px;
    vertical-align: middle;
}

.autopilot-seo-score.high {
    background: #28a745;
}

.autopilot-seo-score.medium {
    background: #ffc107;
    color: #212529;
}

.autopilot-seo-score.low {
    background: #dc3545;
}

/* Link density indicator */
.autopilot-link-density {
    position: fixed;
    top: 50%;
    right: 20px;
    transform: translateY(-50%);
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.autopilot-link-density.show {
    opacity: 1;
}

.autopilot-link-density h4 {
    margin: 0 0 10px 0;
    font-size: 14px;
    color: #333;
}

.autopilot-link-density .density-bar {
    width: 100px;
    height: 8px;
    background: #f1f1f1;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 5px;
}

.autopilot-link-density .density-fill {
    height: 100%;
    background: linear-gradient(90deg, #28a745, #ffc107, #dc3545);
    transition: width 0.3s ease;
}

.autopilot-link-density .density-text {
    font-size: 12px;
    color: #666;
}

/* Accessibility improvements */
.autopilot-internal-link:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .autopilot-internal-link {
        color: #000;
        text-decoration: underline;
        text-decoration-thickness: 2px;
    }
    
    .autopilot-internal-link:hover {
        color: #000;
        background: #ffff00;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .autopilot-internal-link,
    .autopilot-related-posts li,
    .autopilot-link-density {
        transition: none;
    }
    
    .autopilot-internal-link.newly-added {
        animation: none;
        background: #fff3cd;
        padding: 2px 4px;
        border-radius: 3px;
    }
}

/* Print styles */
@media print {
    .autopilot-internal-link {
        color: #000 !important;
        text-decoration: underline !important;
    }
    
    .autopilot-internal-link::after,
    .autopilot-internal-link::before,
    .autopilot-link-density,
    .autopilot-related-posts {
        display: none !important;
    }
}

/* Mobile responsive */
@media (max-width: 768px) {
    .autopilot-internal-link::after {
        display: none;
    }
    
    .autopilot-related-posts {
        margin: 20px 0;
        padding: 15px;
    }
    
    .autopilot-link-density {
        right: 10px;
        transform: translateY(-50%) scale(0.9);
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .autopilot-internal-link {
        color: #4fc3f7;
    }
    
    .autopilot-internal-link:hover {
        color: #29b6f6;
    }
    
    .autopilot-internal-link:visited {
        color: #ba68c8;
    }
    
    .autopilot-related-posts {
        background: #2a2a2a;
        border-left-color: #4fc3f7;
    }
    
    .autopilot-related-posts h3 {
        color: #e0e0e0;
    }
    
    .autopilot-related-posts li {
        background: #1e1e1e;
        border-color: #333;
    }
    
    .autopilot-related-posts a {
        color: #4fc3f7;
    }
    
    .autopilot-related-posts a:hover {
        color: #29b6f6;
    }
    
    .autopilot-related-posts .post-excerpt {
        color: #b0b0b0;
    }
    
    .autopilot-link-density {
        background: #1e1e1e;
        border-color: #333;
    }
    
    .autopilot-link-density h4 {
        color: #e0e0e0;
    }
    
    .autopilot-link-density .density-text {
        color: #b0b0b0;
    }
}

/* Performance optimizations */
.autopilot-internal-link {
    will-change: color;
}

.autopilot-related-posts li {
    will-change: transform;
}

/* Custom scrollbar for tooltips */
.autopilot-internal-link::after::-webkit-scrollbar {
    width: 4px;
}

.autopilot-internal-link::after::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.autopilot-internal-link::after::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 2px;
}

.autopilot-internal-link::after::-webkit-scrollbar-thumb:hover {
    background: #555;
}