/**
 * Estilos para links gerados pelo URL Linkify
 * @author Tiago Schadeck
 * @version 1.0
 */

/* Estilos básicos para links de URL */
.url-link {
    color: #007bff !important;
    text-decoration: underline !important;
    word-break: break-all;
    transition: all 0.2s ease;
    cursor: pointer;
    position: relative;
}

.url-link:hover {
    color: #0056b3 !important;
    text-decoration: none !important;
    background-color: rgba(0, 123, 255, 0.1);
    border-radius: 2px;
    padding: 1px 2px;
}

.url-link:focus {
    outline: 2px solid rgba(0, 123, 255, 0.4);
    outline-offset: 1px;
    border-radius: 2px;
}

/* Estilos específicos para diferentes contextos */

/* Em descrições de tarefas */
.task-description-content .url-link {
    font-weight: 500;
    padding: 2px 4px;
    border-radius: 4px;
    background-color: rgba(0, 123, 255, 0.05);
    border: 1px solid transparent;
}

.task-description-content .url-link:hover {
    border-color: rgba(0, 123, 255, 0.2);
    background-color: rgba(0, 123, 255, 0.1);
    text-decoration: none !important;
}

/* Em cards do kanban */
.task-card .url-link {
    font-size: 0.875rem;
    max-width: 200px;
    display: inline-block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: top;
}

/* Em modais */
.modal .url-link {
    word-break: break-word;
}

/* Em comentários */
.comment-content a {
    color: #0056b3;
    font-weight: 600;
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 2px;
}

.comment-content a:hover {
    color: #003f88;
}

.comment-content .url-link {
    font-weight: 600;
    background-color: rgba(0, 86, 179, 0.08);
    padding: 1px 3px;
    border-radius: 3px;
    display: inline;
    word-break: break-word;
}

.comment-content .url-link:hover {
    background-color: rgba(0, 86, 179, 0.16);
}

/* Em timeline de comentários */
.timeline-item .comment-content .url-link {
    font-size: inherit;
    line-height: inherit;
}

.timeline-item-body .url-link {
    margin: 0 1px;
}

/* Ícone externo para indicar que abre em nova janela */
.url-link::after {
    content: " ↗";
    font-size: 0.8em;
    opacity: 0.6;
    margin-left: 2px;
}

.url-link:hover::after {
    opacity: 1;
}

/* Para links muito longos, adicionar quebra de palavra responsiva */
@media (max-width: 768px) {
    .url-link {
        word-break: break-word;
        hyphens: auto;
    }
    
    .task-card .url-link {
        max-width: 150px;
    }
}

/* Tema escuro (se aplicável) */
@media (prefers-color-scheme: dark) {
    .url-link {
        color: #66b3ff !important;
    }
    
    .url-link:hover {
        color: #4da3ff !important;
        background-color: rgba(102, 179, 255, 0.1);
    }
    
    .task-description-content .url-link {
        background-color: rgba(102, 179, 255, 0.05);
    }
    
    .task-description-content .url-link:hover {
        border-color: rgba(102, 179, 255, 0.2);
        background-color: rgba(102, 179, 255, 0.1);
    }
}

/* Estados de acessibilidade */
.url-link:active {
    transform: translateY(1px);
}

/* Tooltip personalizado para URLs - melhorado */
.url-link[title] {
    position: relative;
    cursor: pointer;
}

.url-link[title]:hover::before {
    content: attr(title);
    position: absolute;
    bottom: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(33, 37, 41, 0.95);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: normal;
    white-space: nowrap;
    z-index: 10000;
    max-width: 450px;
    overflow: hidden;
    text-overflow: ellipsis;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    animation: tooltipFadeIn 0.3s ease-in-out;
    pointer-events: none;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.url-link[title]:hover::after {
    content: '';
    position: absolute;
    bottom: calc(100% + 4px);
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid rgba(33, 37, 41, 0.95);
    z-index: 10000;
    pointer-events: none;
}

/* Tooltip alternativo para links próximos ao topo */
.url-link[title].tooltip-bottom:hover::before {
    bottom: auto;
    top: calc(100% + 10px);
}

.url-link[title].tooltip-bottom:hover::after {
    bottom: auto;
    top: calc(100% + 4px);
    border-top: none;
    border-bottom: 6px solid rgba(33, 37, 41, 0.95);
}

@keyframes tooltipFadeIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(4px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* Ajuste para tooltip em mobile */
@media (max-width: 768px) {
    .url-link[title]:hover::before {
        max-width: 300px;
        font-size: 11px;
        padding: 6px 10px;
        left: 0;
        transform: none;
        white-space: normal;
        word-break: break-all;
        line-height: 1.4;
    }
    
    .url-link[title]:hover::after {
        left: 20px;
        transform: none;
    }
}

/* Tooltip para tema escuro */
@media (prefers-color-scheme: dark) {
    .url-link[title]:hover::before {
        background-color: rgba(248, 249, 250, 0.95);
        color: #212529;
        border: 1px solid rgba(0, 0, 0, 0.1);
    }
    
    .url-link[title]:hover::after {
        border-top-color: rgba(248, 249, 250, 0.95);
    }
    
    .url-link[title].tooltip-bottom:hover::after {
        border-bottom-color: rgba(248, 249, 250, 0.95);
    }
}

/* Garantir que tooltip apareça acima de outros elementos */
.url-link[title]:hover {
    z-index: 9999;
}

/* Animação suave de aparição */
.url-link {
    animation: linkifyFadeIn 0.5s ease-in-out;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes linkifyFadeIn {
    from {
        opacity: 0;
        background-color: rgba(0, 123, 255, 0.3);
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        background-color: rgba(0, 123, 255, 0.05);
        transform: scale(1);
    }
}

/* Melhorar a integração com componentes Bootstrap */
.alert .url-link {
    color: inherit !important;
    text-decoration: underline !important;
    font-weight: 600;
}

.alert-info .url-link {
    color: #0c5460 !important;
}

.alert-success .url-link {
    color: #0f5132 !important;
}

.alert-warning .url-link {
    color: #664d03 !important;
}

.alert-danger .url-link {
    color: #58151c !important;
}
