/* ========================================================================== */
/* DUPLICADOS MODAL - Modal para detectar y resolver duplicados potenciales   */
/* ========================================================================== */

/* Overlay del modal */
.duplicados-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.65);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: duplicadosFadeIn 0.2s ease-out;
}

@keyframes duplicadosFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Contenedor del modal */
.duplicados-modal-container {
    background: var(--bg-secondary);
    border-radius: 12px;
    width: 92%;
    max-width: 92%;
    height: 88vh;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: duplicadosSlideIn 0.3s ease-out;
    border: 1px solid var(--border-color);
    overflow: hidden;
}

@keyframes duplicadosSlideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Header del Modal */
.duplicados-modal-header {
    background: linear-gradient(135deg, #F07400, #00b4ff) !important;
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: 12px 12px 0 0;
    min-height: 50px;
    max-height: 50px;
    border-bottom: none;
    flex-shrink: 0;
}

.duplicados-modal-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #ffffff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    gap: 12px;
}

.duplicados-modal-title .title-badge {
    background: rgba(255, 255, 255, 0.2);
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 500;
}

.duplicados-close-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s ease;
    color: #ffffff;
}

.duplicados-close-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: scale(1.1);
}

.duplicados-close-btn svg {
    width: 20px;
    height: 20px;
}

/* Barra de configuración */
.duplicados-config-bar {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 12px 20px;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.duplicados-config-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.duplicados-config-item label {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.duplicados-config-item select,
.duplicados-config-item input {
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 13px;
    min-width: 80px;
}

.duplicados-config-item select:focus,
.duplicados-config-item input:focus {
    outline: none;
    border-color: #F07400;
}

.duplicados-stats {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 13px;
    color: var(--text-secondary);
}

.duplicados-stats .stat-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.duplicados-stats .stat-value {
    font-weight: 600;
    color: #F07400;
}

/* Contenedor principal con 2 columnas */
.duplicados-content {
    display: grid;
    grid-template-columns: 320px 1fr;
    flex: 1;
    overflow: hidden;
    background: var(--bg-primary);
}

.duplicados-content:focus {
    outline: none;
}

/* Indicador visual de navegación con teclado */
.duplicados-content:focus-visible .duplicados-list-panel {
    box-shadow: inset 0 0 0 2px rgba(240, 116, 0, 0.3);
}

/* Panel izquierdo - Lista de pares */
.duplicados-list-panel {
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-color);
    background: var(--bg-secondary);
    overflow: hidden;
}

.duplicados-list-header {
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.list-header-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.75rem;
    background: linear-gradient(135deg, rgba(240, 116, 0, 0.15), rgba(0, 180, 255, 0.1));
    border: 1px solid rgba(240, 116, 0, 0.4);
    border-radius: 16px;
}

.list-header-badge svg {
    width: 14px;
    height: 14px;
    color: #F07400;
    stroke: #F07400;
    flex-shrink: 0;
}

.list-header-badge > span {
    font-weight: 600;
    font-size: 0.8rem;
    color: #F07400;
}

.list-header-badge .header-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    background: linear-gradient(135deg, #F07400, #00b4ff);
    border-radius: 11px;
    font-size: 0.75rem;
    font-weight: 700;
    color: white;
    box-shadow: 0 0 6px rgba(240, 116, 0, 0.4);
}

.duplicados-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

/* Item de la lista de pares */
.duplicados-pair-item {
    padding: 12px;
    margin-bottom: 8px;
    border-radius: 8px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.2s ease;
}

.duplicados-pair-item:hover {
    border-color: #F07400;
    box-shadow: 0 2px 8px rgba(240, 116, 0, 0.15);
}

.duplicados-pair-item.active {
    border-color: #F07400;
    background: linear-gradient(135deg, rgba(240, 116, 0, 0.1), rgba(0, 180, 255, 0.1));
    box-shadow: 0 2px 12px rgba(240, 116, 0, 0.2);
}

.duplicados-pair-item.resolved {
    opacity: 0.6;
    border-left: 3px solid #28a745;
}

.pair-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.pair-id {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
}

.pair-score {
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.pair-score.high {
    background: linear-gradient(135deg, #dc3545, #ff6b6b);
    color: white;
}

.pair-score.medium {
    background: linear-gradient(135deg, #F07400, #ffa500);
    color: white;
}

.pair-score.low {
    background: linear-gradient(135deg, #6c757d, #adb5bd);
    color: white;
}

.pair-ciclo {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.5);
    padding: 3px 8px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 600;
    color: #ffffff;
    white-space: nowrap;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

.pair-details {
    font-size: 12px;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.pair-details .detail-row {
    display: flex;
    justify-content: space-between;
}

.pair-details .detail-label {
    color: var(--text-tertiary);
}

.pair-details .detail-value {
    font-weight: 500;
}

/* Panel derecho - Comparación */
.duplicados-compare-panel {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 16px;
    gap: 16px;
}

.duplicados-compare-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.compare-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.compare-actions {
    display: flex;
    gap: 10px;
}

.compare-actions button {
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
}

.btn-eliminar-1 {
    background: linear-gradient(135deg, #dc3545, #c82333);
    color: white;
}

.btn-eliminar-1:hover {
    background: linear-gradient(135deg, #c82333, #bd2130);
    transform: translateY(-1px);
}

.btn-eliminar-2 {
    background: linear-gradient(135deg, #dc3545, #c82333);
    color: white;
}

.btn-eliminar-2:hover {
    background: linear-gradient(135deg, #c82333, #bd2130);
    transform: translateY(-1px);
}

.btn-no-duplicado {
    background: linear-gradient(135deg, #28a745, #20c997);
    color: white;
}

.btn-no-duplicado:hover {
    background: linear-gradient(135deg, #20c997, #28a745);
    transform: translateY(-1px);
}

/* Grid de comparación de fotos */
.compare-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    flex: 1;
    overflow: hidden;
}

.compare-item {
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 10px;
    overflow: hidden;
    transition: all 0.2s ease;
}

.compare-item.selected-delete {
    border-color: #dc3545;
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.3);
}

.compare-item-header {
    background: linear-gradient(135deg, #F07400, #00b4ff);
    color: white;
    padding: 10px 14px;
    font-weight: 600;
    font-size: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.compare-item-header .item-label {
    display: flex;
    align-items: center;
    gap: 8px;
}

.compare-item-header .item-id {
    background: rgba(255, 255, 255, 0.2);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
}

.compare-item-header .item-ciclo {
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.5);
    padding: 4px 12px;
    border-radius: 14px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.compare-item-image {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    overflow: hidden;
    min-height: 250px;
    cursor: pointer;
    padding: 12px;
}

.compare-item-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: transform 0.2s ease;
}

.compare-item-image:hover img {
    transform: scale(1.02);
}

.compare-item-image .no-image {
    color: var(--text-secondary);
    font-size: 14px;
}

.compare-item-details {
    padding: 14px 16px;
    background: linear-gradient(180deg, var(--bg-tertiary) 0%, var(--bg-secondary) 100%);
    border-top: 1px solid rgba(240, 116, 0, 0.2);
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    font-size: 12px;
    max-height: 200px;
    overflow-y: auto;
    flex-shrink: 0;
}

.detail-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 8px 10px;
    background: var(--bg-primary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
}

.detail-field:hover {
    border-color: #F07400;
    box-shadow: 0 4px 12px rgba(240, 116, 0, 0.25);
    background: linear-gradient(135deg, rgba(240, 116, 0, 0.08), rgba(0, 180, 255, 0.05));
    transform: translateY(-1px);
}

.detail-field.full-width {
    grid-column: span 2;
}

.detail-field .field-label {
    color: var(--text-tertiary);
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 4px;
}

.detail-field .field-label::before {
    content: '';
    width: 3px;
    height: 3px;
    background: linear-gradient(135deg, #F07400, #00b4ff);
    border-radius: 50%;
}

.detail-field .field-value {
    color: var(--text-primary);
    font-weight: 600;
    font-size: 12px;
    word-break: break-word;
    line-height: 1.4;
    padding: 2px 0;
}

.detail-field .field-value.match {
    color: #00b4ff;
    text-shadow: 0 0 20px rgba(0, 180, 255, 0.3);
}

.detail-field .field-value.no-match {
    color: #dc3545;
    text-shadow: 0 0 20px rgba(220, 53, 69, 0.3);
}

/* Estilo del campo completo cuando coincide */
.detail-field:has(.field-value.match) {
    border-color: rgba(0, 180, 255, 0.3);
    background: linear-gradient(135deg, rgba(0, 180, 255, 0.05), transparent);
}

.detail-field:has(.field-value.match) .field-label::before {
    background: #00b4ff;
    box-shadow: 0 0 6px rgba(0, 180, 255, 0.6);
}

/* Estilo del campo completo cuando NO coincide */
.detail-field:has(.field-value.no-match) {
    border-color: rgba(220, 53, 69, 0.3);
    background: linear-gradient(135deg, rgba(220, 53, 69, 0.05), transparent);
}

.detail-field:has(.field-value.no-match) .field-label::before {
    background: #dc3545;
    box-shadow: 0 0 6px rgba(220, 53, 69, 0.6);
}

/* Estado vacío */
.duplicados-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-secondary);
    gap: 12px;
}

.duplicados-empty svg {
    width: 64px;
    height: 64px;
    opacity: 0.5;
}

.duplicados-empty p {
    font-size: 15px;
    margin: 0;
}

/* Barra inferior de acciones */
.duplicados-footer {
    padding: 12px 20px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.footer-info {
    font-size: 13px;
    color: var(--text-secondary);
}

.footer-info .count {
    font-weight: 600;
    color: #F07400;
}

.footer-actions {
    display: flex;
    gap: 12px;
}

.btn-cancelar {
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: all 0.2s ease;
}

.btn-cancelar:hover {
    background: var(--bg-tertiary);
}

.btn-aplicar {
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    background: linear-gradient(135deg, #F07400, #00b4ff);
    color: white;
    transition: all 0.2s ease;
}

.btn-aplicar:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(240, 116, 0, 0.3);
}

.btn-aplicar:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Scrollbar personalizado */
.duplicados-list::-webkit-scrollbar,
.compare-item-details::-webkit-scrollbar {
    width: 6px;
}

.duplicados-list::-webkit-scrollbar-track,
.compare-item-details::-webkit-scrollbar-track {
    background: var(--bg-primary);
    border-radius: 3px;
}

.duplicados-list::-webkit-scrollbar-thumb,
.compare-item-details::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.duplicados-list::-webkit-scrollbar-thumb:hover,
.compare-item-details::-webkit-scrollbar-thumb:hover {
    background: #F07400;
}

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

@media (max-width: 1200px) {
    .duplicados-modal-container {
        width: 95%;
        max-width: 95%;
    }

    .duplicados-content {
        grid-template-columns: 280px 1fr;
    }
}

@media (max-width: 992px) {
    .duplicados-content {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
    }

    .duplicados-list-panel {
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        max-height: 200px;
    }

    .duplicados-list {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        gap: 8px;
        padding: 8px;
    }

    .duplicados-pair-item {
        flex-shrink: 0;
        width: 200px;
        margin-bottom: 0;
    }

    .compare-grid {
        grid-template-columns: 1fr;
        overflow-y: auto;
    }
}

@media (max-width: 768px) {
    .duplicados-modal-container {
        width: 98%;
        height: 95vh;
        max-height: 95vh;
    }

    .duplicados-config-bar {
        flex-wrap: wrap;
        gap: 12px;
        padding: 10px 16px;
    }

    .duplicados-stats {
        width: 100%;
        margin-left: 0;
        justify-content: center;
    }

    .compare-actions {
        flex-wrap: wrap;
        justify-content: center;
    }

    .compare-actions button {
        flex: 1;
        min-width: 120px;
    }

    .duplicados-footer {
        flex-direction: column;
        gap: 12px;
    }

    .footer-actions {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 576px) {
    .duplicados-modal-header {
        padding: 12px 16px;
    }

    .duplicados-modal-title {
        font-size: 14px;
    }

    .compare-item-details {
        grid-template-columns: 1fr;
    }

    .detail-field.full-width {
        grid-column: span 1;
    }
}
