/* BIOGRAPHY-MODAL.CSS
 * Estilos para o modal de visualização de biografias
 * Baseado no estilo do footnote-modal para manter consistência visual
 */

.biography-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Follow theme "surface" choices (author box is the closest visual sibling) */
    --bio-modal-bg: var(--author-box-bg, var(--surface));
    --bio-modal-border-base: var(--author-box-border-base, var(--surface));
    --bio-modal-border: color-mix(in srgb, var(--bio-modal-border-base) 88%, var(--border-ink) 12%);
    --bio-modal-hairline: color-mix(in srgb, var(--bio-modal-border-base) 92%, var(--border-ink) 8%);
    --bio-modal-surface-2: color-mix(in srgb, var(--bio-modal-bg) 88%, var(--bg) 12%);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.biography-modal--visible {
    opacity: 1;
    pointer-events: all;
}

.biography-modal--closing {
    opacity: 0;
}

.biography-modal__backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(2px);
}

.biography-modal__content {
    position: relative;
    max-width: 720px;
    width: 92%;
    max-height: 80vh;
    background: var(--bio-modal-bg);
    border: 1px solid var(--bio-modal-border);
    border-radius: 12px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.35);
    overflow: hidden;
    transform: translateY(20px) scale(0.98);
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.biography-modal--visible .biography-modal__content {
    transform: translateY(0) scale(1);
}

.biography-modal__close {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: transparent;
    border: none;
    color: var(--text);
    cursor: pointer;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    opacity: 0.9;
    z-index: 2;
}

.biography-modal__close i {
    width: 1.125rem;
    height: 1.125rem;
}

.biography-modal__inner {
    padding: 1.25rem 1.5rem 1.5rem 1.5rem;
    max-height: calc(80vh - 48px);
    overflow-y: auto;
    color: var(--text);
}

.biography-modal__header {
    display: flex;
    gap: 1rem;
    align-items: center;
    padding: 1rem 1.25rem 0 1.25rem;
    border-bottom: 1px solid var(--bio-modal-hairline);
    background: transparent;
}

.biography-modal__photo {
    width: 96px;
    height: 96px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--bio-modal-border);
}

.biography-modal__photo--placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    background: color-mix(in srgb, var(--card-bg, var(--surface-2)) 80%, transparent);
    color: var(--link);
}

.biography-modal__photo--placeholder svg {
    width: 44px;
    height: 44px;
}

.biography-modal__title h3 {
    margin: 0;
    font-family: var(--font-display);
    font-size: 1.25rem;
    color: var(--heading);
}

.biography-modal__body {
    padding: 0.75rem 1.25rem 1.25rem 1.25rem;
    color: var(--article-text);
}

/* Forçar cores do tema (override do conteúdo Summernote) */
.biography-modal__inner * {
    color: inherit;
}

[data-theme="dark"] .biography-modal__backdrop {
    background-color: rgba(0, 0, 0, 0.55);
}

@media (max-width: 768px) {
    .biography-modal__photo {
        width: 72px;
        height: 72px;
    }

    .biography-modal__content {
        width: 96%;
        max-height: 88vh;
    }

    .biography-modal__inner {
        padding: 1rem;
    }
}


/* === TABELAS NA BIOGRAFIA (Mesmo estilo de artigos) ==================== */

.biography-modal__body table {
    width: 100%;
    border-collapse: collapse;
    margin: var(--space-lg) 0;
    font-family: var(--font-body);
    font-size: var(--text-sm);
    line-height: var(--leading-normal);
    background: var(--bio-modal-bg);
    border: 1px solid var(--bio-modal-border);
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    overflow: hidden;
}

/* Cabeçalho da tabela (apenas thead, não primeira linha de dados) - destacado */
.biography-modal__body table thead,
.biography-modal__body table thead tr {
    background: var(--accent-2-dark);
    border-bottom: 2px solid var(--bio-modal-hairline);
}

.biography-modal__body table thead th {
    padding: var(--space-sm) var(--space-md);
    text-align: left;
    font-weight: var(--weight-semibold);
    color: var(--heading);
    font-family: var(--font-display);
    font-size: var(--text-sm);
    border-bottom: 2px solid var(--bio-modal-hairline);
    border-right: 1px solid var(--bio-modal-border);
    background: transparent !important;
}

.biography-modal__body table thead th:last-child {
    border-right: none;
}

/* Garantir que texto do cabeçalho seja legível no tema claro */
[data-theme="light"] .biography-modal__body table thead th {
    color: #faf7f2;
    /* Cor clara para contraste com fundo escuro */
}


/* Corpo da tabela */
.biography-modal__body table tbody {
    background: var(--bio-modal-bg);
}

.biography-modal__body table tbody tr {
    border-bottom: 1px solid var(--bio-modal-border);
    transition: background-color 0.2s ease;
}

.biography-modal__body table tbody tr:last-child {
    border-bottom: none;
}

/* Linhas alternadas (zebra striping sutil) */
.biography-modal__body table tbody tr:nth-child(even) {
    background: var(--bio-modal-surface-2);
}

.biography-modal__body table tbody tr:hover {
    background: var(--bio-modal-surface-2);
    box-shadow: inset 0 0 0 1px var(--bio-modal-hairline);
}

/* Células do corpo */
.biography-modal__body table tbody td {
    padding: var(--space-sm) var(--space-md);
    color: var(--text);
    border-right: 1px solid var(--bio-modal-border);
    vertical-align: top;
}

/* Forçar cores do tema, sobrescrevendo qualquer cor inline do Summernote */
.biography-modal__body table *[style*="color"],
.biography-modal__body table *[style*="Color"],
.biography-modal__body table *[style*="COLOR"],
.biography-modal__body table td *[style*="color"],
.biography-modal__body table td *[style*="Color"],
.biography-modal__body table td *[style*="COLOR"],
.biography-modal__body table td span[style*="color"],
.biography-modal__body table td span[style*="Color"],
.biography-modal__body table td span[style*="COLOR"],
.biography-modal__body table td p[style*="color"],
.biography-modal__body table td p[style*="Color"],
.biography-modal__body table td p[style*="COLOR"] {
    color: var(--text);
}

.biography-modal__body table thead *[style*="color"],
.biography-modal__body table thead *[style*="Color"],
.biography-modal__body table thead *[style*="COLOR"] {
    color: var(--heading);
}

/* Tema claro: texto do cabeçalho deve ser claro */
[data-theme="light"] .biography-modal__body table thead *[style*="color"] {
    color: #faf7f2;
}

.biography-modal__body table tbody td:last-child {
    border-right: none;
}

/* Estilos para conteúdo dentro das células */
.biography-modal__body table td p,
.biography-modal__body table th p {
    margin: 0;
    padding: 0;
    text-indent: 0 !important;
}

.biography-modal__body table td p+p {
    margin-top: var(--space-xs);
}

/* Responsive: tabelas em telas pequenas */
@media (max-width: 768px) {
    .biography-modal__body table {
        font-size: var(--text-sm);
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .biography-modal__body table thead th,
    .biography-modal__body table tbody td {
        padding: var(--space-xs) var(--space-sm);
        white-space: nowrap;
    }
}



/* === TOOLTIP DE BIOGRAFIA (Hover na referência) ======================== */

.bio-ref {
    position: relative;
    /* Não forçar nowrap para não quebrar fluxo do texto se for longo */
    cursor: pointer;
    z-index: 1;
}

.bio-ref__tooltip {
    display: none !important;
    /* Começa oculto */
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    --bio-tooltip-bg: color-mix(in srgb, var(--card-bg, var(--surface-2)) 70%, transparent);
    background-color: var(--bio-tooltip-bg);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    padding: 4px;
    /* Moldura fina */
    border: 1px solid var(--bio-modal-border);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 9999;
    /* Z-index alto para aparecer sobre tabelas e outros elementos */
    pointer-events: none;
    width: max-content;
}

/* Seta do tooltip */
.bio-ref__tooltip::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -4px;
    border-width: 4px;
    border-style: solid;
    border-color: var(--bio-tooltip-bg) transparent transparent transparent;
    z-index: 2;
}

.bio-ref__tooltip::before {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: var(--border) transparent transparent transparent;
    z-index: 1;
}

.bio-ref__tooltip img {
    display: block;
    width: 100px;
    border-radius: 8px;
    object-fit: cover;
    background-color: var(--bg-2);
    margin: 0 !important;
}

.bio-ref__tooltip-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100px;
    height: 100px;
    border-radius: 8px;
    background-color: var(--bg-2);
    color: var(--link);
}

.bio-ref__tooltip-placeholder svg {
    width: 44px;
    height: 44px;
}

.bio-ref:hover .bio-ref__tooltip {
    display: block !important;
    animation: fadeInTooltip 0.2s ease-out forwards;
}

.bio-ref:hover {
    z-index: 12000;
}

.article-content .article-body-wrap.article-card,
.article-content .article-body-wrap.article-card > .article-card__content {
    overflow: visible !important;
}

@keyframes fadeInTooltip {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-4px);
    }

    to {
        opacity: 1;
        transform: translateX(-50%) translateY(-8px);
    }
}
