/**
 * Estilos del panel de Bibliografia
 * Sistema de referencias para Legado.art
 */

/* =============================================
   MODAL DE BIBLIOGRAFIA (antes panel lateral)
   ============================================= */

.bibliografia-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.bibliografia-overlay.open {
    opacity: 1;
    visibility: visible;
}

.bibliografia-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    width: 90%;
    max-width: 800px;
    height: 85vh;
    max-height: 700px;
    background: #0A1F18;
    border: 1px solid rgba(176, 140, 62, 0.3);
    border-radius: 12px;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.bibliografia-panel.open {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

/* Header del panel */
.bib-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid rgba(176, 140, 62, 0.2);
    background: #0F2A22;
}

.bib-panel-header h3 {
    margin: 0;
    font-family: "Palatino Linotype", "Garamond", serif;
    font-size: 1.25rem;
    color: #ffb766;
}

.bib-close-btn {
    background: transparent;
    border: none;
    color: #F4ECE2;
    cursor: pointer;
    padding: 8px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.bib-close-btn:hover {
    background: rgba(176, 140, 62, 0.2);
    color: #ffb766;
}

/* Contenido del panel */
.bib-panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

/* Secciones */
.bib-section {
    margin-bottom: 24px;
}

.bib-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: rgba(244, 236, 226, 0.7);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* La i de info-tooltip debe mantener su estilo exacto */
.bib-label .info-tooltip {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    min-width: 18px;
    min-height: 18px;
    margin-left: 0;
    background: rgba(176, 140, 62, 0.25);
    border: 1px solid rgba(176, 140, 62, 0.5);
    border-radius: 50%;
    font-family: Georgia, serif;
    font-size: 11px;
    font-style: italic;
    font-weight: 600;
    color: #B08C3E;
    text-transform: none;
    letter-spacing: 0;
    cursor: help;
}

/* =============================================
   SELECTOR DE MODO (Bibliografia / Notas)
   ============================================= */

.bib-modo-selector {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.bib-modo-btn {
    flex: 1;
    padding: 12px 16px;
    background: rgba(244, 236, 226, 0.05);
    border: 1px solid rgba(176, 140, 62, 0.25);
    border-radius: 8px;
    color: rgba(244, 236, 226, 0.7);
    font-family: Georgia, serif;
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.bib-modo-btn:hover {
    border-color: rgba(176, 140, 62, 0.5);
    background: rgba(176, 140, 62, 0.1);
}

.bib-modo-btn.active {
    background: rgba(176, 140, 62, 0.2);
    border-color: #B08C3E;
    color: #ffb766;
}

.bib-modo-btn svg {
    flex-shrink: 0;
}

.bib-modo-descripcion {
    font-size: 0.8rem;
    color: rgba(244, 236, 226, 0.5);
    margin: 0;
    line-height: 1.4;
    font-style: italic;
}

/* =============================================
   SELECTOR DE ESTILO
   ============================================= */

.bib-estilo-selector {
    display: flex;
    gap: 8px;
}

.bib-estilo-btn {
    flex: 1;
    padding: 10px 16px;
    background: rgba(244, 236, 226, 0.08);
    border: 1px solid rgba(176, 140, 62, 0.3);
    border-radius: 6px;
    color: #F4ECE2;
    font-family: Georgia, serif;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.bib-estilo-btn:hover {
    border-color: #B08C3E;
    background: rgba(176, 140, 62, 0.15);
}

.bib-estilo-btn.active {
    background: rgba(176, 140, 62, 0.25);
    border-color: #B08C3E;
    color: #ffb766;
}

/* =============================================
   BUSCADOR
   ============================================= */

.bib-search-container {
    position: relative;
}

.bib-search-input {
    width: 100%;
    padding: 12px 16px;
    background: rgba(244, 236, 226, 0.08);
    border: 1px solid rgba(176, 140, 62, 0.4);
    border-radius: 6px;
    color: #F4ECE2;
    font-family: Georgia, serif;
    font-size: 0.95rem;
    box-sizing: border-box;
}

.bib-search-input:focus {
    outline: none;
    border-color: #ffb766;
    background: rgba(244, 236, 226, 0.12);
}

.bib-search-input::placeholder {
    color: rgba(244, 236, 226, 0.4);
}

.bib-search-hint {
    font-size: 0.75rem;
    color: rgba(244, 236, 226, 0.5);
    margin-top: 8px;
    display: flex;
    align-items: flex-start;
    gap: 6px;
    background: rgba(176, 140, 62, 0.08);
    padding: 10px 12px;
    border-radius: 6px;
    border-left: 3px solid #B08C3E;
    line-height: 1.4;
}

.bib-search-hint svg {
    flex-shrink: 0;
    color: #B08C3E;
    margin-top: 1px;
}


/* Resultados de busqueda */
.bib-search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #0F2A22;
    border: 1px solid rgba(176, 140, 62, 0.4);
    border-top: none;
    border-radius: 0 0 6px 6px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 10;
    display: none;
}

.bib-search-loading,
.bib-search-empty,
.bib-search-error {
    padding: 16px;
    text-align: center;
    color: rgba(244, 236, 226, 0.6);
    font-size: 0.9rem;
}

.bib-search-error {
    color: #e74c3c;
}

.bib-search-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(176, 140, 62, 0.1);
    transition: background 0.2s ease;
}

.bib-search-item:hover {
    background: rgba(176, 140, 62, 0.15);
}

.bib-search-item:last-child {
    border-bottom: none;
}

.bib-search-item-main {
    flex: 1;
    cursor: pointer;
    min-width: 0;
}

/* Boton de favorito */
.bib-favorite-btn {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid rgba(176, 140, 62, 0.3);
    border-radius: 50%;
    cursor: pointer;
    color: rgba(244, 236, 226, 0.5);
    transition: all 0.2s ease;
}

.bib-favorite-btn:hover {
    background: rgba(176, 140, 62, 0.2);
    border-color: #B08C3E;
    color: #ffb766;
}

.bib-favorite-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.bib-favorite-btn.active {
    background: rgba(231, 76, 60, 0.2);
    border-color: #e74c3c;
    color: #e74c3c;
}

.bib-favorite-btn.active svg {
    fill: #e74c3c;
}

/* Header con tipo y fuente */
.bib-search-item-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
}

.bib-search-item-tipo {
    display: inline-block;
    font-size: 0.7rem;
    text-transform: uppercase;
    padding: 2px 6px;
    background: rgba(176, 140, 62, 0.3);
    border-radius: 3px;
    color: #ffb766;
}

/* Badge de fuente */
.bib-search-item-fuente {
    display: inline-block;
    font-size: 0.65rem;
    text-transform: uppercase;
    padding: 2px 6px;
    border-radius: 3px;
    font-weight: 500;
    letter-spacing: 0.3px;
}

/* Colores por fuente */
.bib-fuente-openlibrary {
    background: rgba(70, 130, 180, 0.3);
    color: #87CEEB;
}

.bib-fuente-googlebooks {
    background: rgba(66, 133, 244, 0.3);
    color: #8AB4F8;
}

.bib-fuente-doaj {
    background: rgba(34, 139, 34, 0.3);
    color: #90EE90;
}

.bib-fuente-openalex {
    background: rgba(200, 80, 80, 0.3);
    color: #F4A0A0;
}

.bib-fuente-europepmc {
    background: rgba(255, 165, 0, 0.3);
    color: #FFD280;
}

/* Badge de ISBN */
.bib-isbn-badge {
    display: inline-block;
    font-size: 0.65rem;
    padding: 2px 6px;
    background: rgba(176, 140, 62, 0.3);
    border-radius: 3px;
    color: #ffb766;
    font-family: monospace;
    letter-spacing: 0.5px;
}

.bib-search-item-titulo {
    font-size: 0.95rem;
    color: #F4ECE2;
    margin-bottom: 2px;
    line-height: 1.3;
}

.bib-search-item-autor {
    font-size: 0.8rem;
    color: rgba(244, 236, 226, 0.6);
}

.bib-search-item-anio {
    font-size: 0.75rem;
    color: rgba(176, 140, 62, 0.8);
    margin-top: 2px;
}

/* =============================================
   BOTON AÑADIR MANUAL
   ============================================= */

.bib-add-manual-btn {
    width: 100%;
    padding: 12px 16px;
    background: transparent;
    border: 1px dashed rgba(176, 140, 62, 0.5);
    border-radius: 6px;
    color: #F4ECE2;
    font-family: Georgia, serif;
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.bib-add-manual-btn:hover {
    border-color: #B08C3E;
    background: rgba(176, 140, 62, 0.1);
    color: #ffb766;
}

/* =============================================
   FORMULARIO MANUAL
   ============================================= */

.bib-form-manual {
    background: rgba(176, 140, 62, 0.08);
    border: 1px solid rgba(176, 140, 62, 0.25);
    border-radius: 8px;
    padding: 16px;
}

.bib-form-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.bib-form-header span {
    font-family: "Palatino Linotype", "Garamond", serif;
    font-size: 1rem;
    color: #ffb766;
}

.bib-form-close {
    background: transparent;
    border: none;
    color: rgba(244, 236, 226, 0.6);
    font-size: 0.85rem;
    cursor: pointer;
    padding: 4px 8px;
}

.bib-form-close:hover {
    color: #F4ECE2;
}

.bib-form-group {
    margin-bottom: 12px;
}

.bib-form-group label {
    display: block;
    font-size: 0.8rem;
    color: rgba(244, 236, 226, 0.7);
    margin-bottom: 4px;
}

.bib-form-group input,
.bib-form-group select {
    width: 100%;
    padding: 10px 12px;
    background: rgba(244, 236, 226, 0.08);
    border: 1px solid rgba(176, 140, 62, 0.3);
    border-radius: 4px;
    color: #F4ECE2;
    font-family: Georgia, serif;
    font-size: 0.9rem;
    box-sizing: border-box;
}

.bib-form-group input:focus,
.bib-form-group select:focus {
    outline: none;
    border-color: #ffb766;
}

.bib-form-group input::placeholder {
    color: rgba(244, 236, 226, 0.4);
}

.bib-form-group select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none'%3E%3Cpath d='M3 4.5L6 7.5L9 4.5' stroke='%23B08C3E' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

.bib-form-group select option {
    background: #0F2A22;
    color: #F4ECE2;
}

.bib-form-row {
    display: flex;
    gap: 12px;
}

.bib-form-row .bib-form-group {
    flex: 1;
}

.bib-form-submit {
    width: 100%;
    padding: 12px 16px;
    background: linear-gradient(135deg, #B08C3E 0%, #8A6A29 100%);
    border: none;
    border-radius: 6px;
    color: white;
    font-family: Georgia, serif;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 8px;
    transition: all 0.2s ease;
}

.bib-form-submit:hover {
    background: linear-gradient(135deg, #D4BC8A 0%, #B08C3E 100%);
}

/* =============================================
   LISTA DE REFERENCIAS
   ============================================= */

.bib-lista {
    max-height: 400px;
    overflow-y: auto;
}

.bib-lista-vacia {
    text-align: center;
    color: rgba(244, 236, 226, 0.5);
    font-size: 0.9rem;
    padding: 20px;
    font-style: italic;
}

.bib-item {
    display: flex;
    gap: 12px;
    padding: 12px;
    background: rgba(244, 236, 226, 0.05);
    border: 1px solid rgba(176, 140, 62, 0.2);
    border-radius: 6px;
    margin-bottom: 8px;
}

.bib-item:hover {
    border-color: rgba(176, 140, 62, 0.4);
}

.bib-item-numero {
    font-family: "Palatino Linotype", "Garamond", serif;
    font-size: 0.9rem;
    color: #ffb766;
    font-weight: 600;
    flex-shrink: 0;
}

.bib-item-content {
    flex: 1;
    min-width: 0;
}

.bib-item-texto {
    font-size: 0.85rem;
    color: #F4ECE2;
    line-height: 1.5;
    margin-bottom: 8px;
    word-wrap: break-word;
}

.bib-item-texto em {
    font-style: italic;
    color: rgba(244, 236, 226, 0.9);
}

.bib-item-actions {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.bib-item-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background: rgba(176, 140, 62, 0.15);
    border: 1px solid rgba(176, 140, 62, 0.3);
    border-radius: 4px;
    color: #F4ECE2;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.bib-item-btn:hover {
    background: rgba(176, 140, 62, 0.3);
    border-color: #B08C3E;
}

.bib-item-btn-delete:hover {
    background: rgba(231, 76, 60, 0.2);
    border-color: #e74c3c;
    color: #e74c3c;
}

.bib-item-btn-move {
    padding: 4px 6px;
}

/* =============================================
   ORDENACION Y DRAG & DROP
   ============================================= */

.bib-ordenacion {
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(176, 140, 62, 0.15);
}

.bib-ordenacion-btns {
    display: flex;
    align-items: center;
    gap: 12px;
}

.bib-orden-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: rgba(176, 140, 62, 0.15);
    border: 1px solid rgba(176, 140, 62, 0.3);
    border-radius: 6px;
    color: #F4ECE2;
    font-family: Georgia, serif;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.bib-orden-btn:hover {
    background: rgba(176, 140, 62, 0.25);
    border-color: #B08C3E;
    color: #ffb766;
}

.bib-orden-hint {
    font-size: 0.75rem;
    color: rgba(244, 236, 226, 0.4);
    font-style: italic;
}

/* Drag & Drop */
.bib-item {
    cursor: grab;
}

.bib-item:active {
    cursor: grabbing;
}

.bib-item.dragging {
    opacity: 0.5;
    border: 1px dashed #B08C3E;
}

.bib-item.drag-over {
    border-color: #ffb766;
    background: rgba(176, 140, 62, 0.15);
}

/* Item de nota (con numero) */
.bib-item-nota {
    padding-left: 8px;
}

/* =============================================
   CITAS EN EL TEXTO (TinyMCE y visualizacion)
   ============================================= */

.cita-ref {
    color: #B08C3E;
    cursor: pointer;
    font-weight: 600;
    transition: color 0.2s ease;
}

.cita-ref:hover {
    color: #ffb766;
    text-decoration: underline;
}

/* =============================================
   NOTAS AL FINAL (Vista Scroll)
   ============================================= */

.notas-referencias {
    margin-top: 60px;
    padding-top: 40px;
    border-top: 2px solid rgba(176, 140, 62, 0.3);
}

.notas-referencias h3 {
    font-family: "Palatino Linotype", "Garamond", serif;
    font-size: 1.5rem;
    color: #ffb766;
    margin-bottom: 24px;
}

.nota-item {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    padding: 12px;
    background: rgba(176, 140, 62, 0.05);
    border-left: 3px solid #B08C3E;
    border-radius: 0 6px 6px 0;
}

.nota-item-numero {
    font-family: "Palatino Linotype", "Garamond", serif;
    font-size: 0.9rem;
    color: #ffb766;
    font-weight: 600;
    flex-shrink: 0;
}

.nota-item-texto {
    font-size: 0.9rem;
    color: #F4ECE2;
    line-height: 1.6;
}

.nota-item-texto em {
    font-style: italic;
}

/* =============================================
   NOTAS AL PIE (Vista Libro)
   ============================================= */

.notas-pie-pagina {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid rgba(176, 140, 62, 0.2);
    font-size: 0.8rem;
}

.nota-pie {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
    color: rgba(244, 236, 226, 0.8);
}

.nota-pie-numero {
    color: #B08C3E;
    font-weight: 600;
}

.nota-pie-texto {
    line-height: 1.5;
}

.nota-pie-texto em {
    font-style: italic;
}

/* Animacion de highlight al hacer click en cita */
.nota-item.highlight,
.nota-item.nota-highlight {
    animation: highlight-pulse 2s ease;
}

@keyframes highlight-pulse {
    0%, 100% {
        background: rgba(176, 140, 62, 0.05);
    }
    50% {
        background: rgba(176, 140, 62, 0.25);
        border-left-color: #ffb766;
    }
}

/* Links en las referencias */
.nota-item-texto a {
    color: #B08C3E;
    text-decoration: none;
    word-break: break-all;
}

.nota-item-texto a:hover {
    color: #ffb766;
    text-decoration: underline;
}

/* =============================================
   BIBLIOGRAFIA GENERAL (Anexo)
   ============================================= */

.bibliografia-anexo {
    margin-top: 60px;
    padding-top: 40px;
    border-top: 2px solid rgba(176, 140, 62, 0.3);
}

.bibliografia-anexo h3 {
    font-family: "Palatino Linotype", "Garamond", serif;
    font-size: 1.5rem;
    color: #ffb766;
    margin-bottom: 24px;
}

.bibliografia-lista {
    list-style: none;
    padding: 0;
    margin: 0;
}

.bibliografia-item {
    padding: 12px 16px;
    margin-bottom: 12px;
    background: rgba(176, 140, 62, 0.05);
    border-left: 3px solid rgba(176, 140, 62, 0.4);
    border-radius: 0 6px 6px 0;
    font-size: 0.95rem;
    color: #F4ECE2;
    line-height: 1.6;
}

.bibliografia-item em {
    font-style: italic;
}

/* Titulo de notas */
.notas-titulo {
    font-family: "Palatino Linotype", "Garamond", serif;
    font-size: 1.3rem;
    color: #ffb766;
    margin-bottom: 20px;
}

/* Numero de nota */
.nota-numero {
    color: #ffb766;
    font-weight: 600;
    flex-shrink: 0;
}

/* =============================================
   BIBLIOGRAFIA EN VISTA LIBRO (ultima pagina)
   ============================================= */

.bibliografia-pagina-libro {
    padding: 20px 0;
}

.bibliografia-titulo-libro {
    font-family: "Palatino Linotype", "Garamond", serif;
    font-size: 1.8rem;
    color: #0F2A22;
    margin-bottom: 30px;
    text-align: center;
    border-bottom: 2px solid #0F2A22;
    padding-bottom: 15px;
}

.bibliografia-lista-libro {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.bibliografia-item-libro {
    padding: 12px 16px;
    background: rgba(15, 42, 34, 0.05);
    border-left: 3px solid #0F2A22;
    border-radius: 0 6px 6px 0;
    font-size: 0.95rem;
    color: #1a1a1a;
    line-height: 1.6;
}

.bibliografia-item-libro em {
    font-style: italic;
}

/* Notas al pie en vista libro - colores oscuros para fondo claro */
.book-page-footnotes {
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid #0F2A22;
    font-size: 0.8rem;
    color: #333;
}

.book-page-footnotes .nota-pie {
    display: flex;
    gap: 8px;
    margin-bottom: 6px;
    line-height: 1.4;
}

.book-page-footnotes .nota-pie-numero {
    color: #0F2A22;
    font-weight: 600;
    min-width: 18px;
}

.book-page-footnotes .nota-pie-texto {
    flex: 1;
    color: #333;
}

.book-page-footnotes .nota-pie-texto em {
    font-style: italic;
}

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

@media (max-width: 768px) {
    .bibliografia-panel {
        width: 95%;
        max-width: none;
        height: 90vh;
        max-height: none;
    }

    .bib-panel-header {
        padding: 16px;
    }

    .bib-panel-header h3 {
        font-size: 1.1rem;
    }

    .bib-panel-content {
        padding: 16px;
    }

    .bib-estilo-selector {
        flex-wrap: wrap;
    }

    .bib-estilo-btn {
        flex: 1 1 calc(33% - 6px);
    }

    .bib-form-row {
        flex-direction: column;
        gap: 0;
    }

    .bib-modo-selector {
        flex-direction: column;
    }

    .bib-modo-btn {
        padding: 10px 12px;
    }
}

/* =============================================
   SCROLLBAR PERSONALIZADO
   ============================================= */

.bib-panel-content::-webkit-scrollbar,
.bib-lista::-webkit-scrollbar,
.bib-search-results::-webkit-scrollbar {
    width: 6px;
}

.bib-panel-content::-webkit-scrollbar-track,
.bib-lista::-webkit-scrollbar-track,
.bib-search-results::-webkit-scrollbar-track {
    background: rgba(244, 236, 226, 0.05);
}

.bib-panel-content::-webkit-scrollbar-thumb,
.bib-lista::-webkit-scrollbar-thumb,
.bib-search-results::-webkit-scrollbar-thumb {
    background: rgba(176, 140, 62, 0.4);
    border-radius: 3px;
}

.bib-panel-content::-webkit-scrollbar-thumb:hover,
.bib-lista::-webkit-scrollbar-thumb:hover,
.bib-search-results::-webkit-scrollbar-thumb:hover {
    background: rgba(176, 140, 62, 0.6);
}
